/
main.js
95 lines (79 loc) · 2.12 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Generated by CoffeeScript 1.5.0
(function() {
var EventEmitter, Module, mixer,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
if (typeof process !== "undefined" && process !== null) {
EventEmitter = require('events').EventEmitter;
} else {
EventEmitter = require('emitter');
}
Module = (function(_super) {
__extends(Module, _super);
function Module(o) {
this._ = {
props: {}
};
if (o != null) {
this.set(o);
}
}
Module.prototype.get = function(k) {
return this._.props[k];
};
Module.prototype.getAll = function() {
return this._.props;
};
Module.prototype.set = function(k, v, silent) {
var ky;
if (k == null) {
return;
}
if (typeof k === 'object') {
for (ky in k) {
v = k[ky];
this.set(ky, v, silent);
}
return this;
} else {
this._.props[k] = v;
if (!silent) {
this.emit("change", k, v);
this.emit("change:" + k, v);
}
return this;
}
};
Module.prototype.clear = function(silent) {
var k, v, _ref;
_ref = this._.props;
for (k in _ref) {
v = _ref[k];
this.remove(k, silent);
}
return this;
};
Module.prototype.has = function(k) {
return this._.props[k] != null;
};
Module.prototype.remove = function(k, silent) {
delete this._.props[k];
if (!silent) {
this.emit("change", k);
this.emit("change:" + k);
this.emit("remove", k);
this.emit("remove:" + k);
}
return this;
};
Module.prototype.toJSON = function() {
return this.getAll();
};
return Module;
})(EventEmitter);
mixer = {
Module: Module,
Emitter: EventEmitter
};
module.exports = mixer;
}).call(this);