]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/grim/node_modules/emissary/node_modules/mixto/lib/mixin.js
a6fdd4f97883d47222bd1418db3011c302485213
[rbdr/dotfiles] / atom / packages / ex-mode / node_modules / space-pen / node_modules / grim / node_modules / emissary / node_modules / mixto / lib / mixin.js
1 (function() {
2 var ExcludedClassProperties, ExcludedPrototypeProperties, Mixin, name;
3
4 module.exports = Mixin = (function() {
5 Mixin.includeInto = function(constructor) {
6 var name, value, _ref;
7 this.extend(constructor.prototype);
8 for (name in this) {
9 value = this[name];
10 if (ExcludedClassProperties.indexOf(name) === -1) {
11 if (!constructor.hasOwnProperty(name)) {
12 constructor[name] = value;
13 }
14 }
15 }
16 return (_ref = this.included) != null ? _ref.call(constructor) : void 0;
17 };
18
19 Mixin.extend = function(object) {
20 var name, _i, _len, _ref, _ref1;
21 _ref = Object.getOwnPropertyNames(this.prototype);
22 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
23 name = _ref[_i];
24 if (ExcludedPrototypeProperties.indexOf(name) === -1) {
25 if (!object.hasOwnProperty(name)) {
26 object[name] = this.prototype[name];
27 }
28 }
29 }
30 return (_ref1 = this.prototype.extended) != null ? _ref1.call(object) : void 0;
31 };
32
33 function Mixin() {
34 if (typeof this.extended === "function") {
35 this.extended();
36 }
37 }
38
39 return Mixin;
40
41 })();
42
43 ExcludedClassProperties = ['__super__'];
44
45 for (name in Mixin) {
46 ExcludedClassProperties.push(name);
47 }
48
49 ExcludedPrototypeProperties = ['constructor', 'extended'];
50
51 }).call(this);