UNPKG

2 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.7.1
2var Module, moduleKeywords,
3 __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
4 __slice = [].slice;
5
6moduleKeywords = ['extended', 'included'];
7
8exports.Module = Module = (function() {
9 function Module() {}
10
11 Module["extends"] = function(obj) {
12 var key, value, _ref;
13 for (key in obj) {
14 value = obj[key];
15 if (__indexOf.call(moduleKeywords, key) < 0) {
16 this[key] = value;
17 }
18 }
19 if ((_ref = obj.extended) != null) {
20 _ref.call(this, this);
21 }
22 return this;
23 };
24
25 Module.includes = function(obj) {
26 var key, value, _ref;
27 for (key in obj) {
28 value = obj[key];
29 if (__indexOf.call(moduleKeywords, key) < 0) {
30 this.prototype[key] = value;
31 }
32 }
33 if ((_ref = obj.included) != null) {
34 _ref.call(this, this);
35 }
36 return this;
37 };
38
39 Module.delegate = function() {
40 var args, source, target, _i, _len, _results;
41 args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
42 target = args.pop();
43 _results = [];
44 for (_i = 0, _len = args.length; _i < _len; _i++) {
45 source = args[_i];
46 _results.push(this.prototype[source] = target.prototype[source]);
47 }
48 return _results;
49 };
50
51 Module.aliasFunction = function(to, from) {
52 return this.prototype[to] = (function(_this) {
53 return function() {
54 var args;
55 args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
56 return _this.prototype[from].apply(_this, args);
57 };
58 })(this);
59 };
60
61 Module.aliasProperty = function(to, from) {
62 return Object.defineProperty(this.prototype, to, {
63 get: function() {
64 return this[from];
65 },
66 set: function(val) {
67 return this[from] = val;
68 }
69 });
70 };
71
72 Module.included = function(func) {
73 return func.call(this, this.prototype);
74 };
75
76 return Module;
77
78})();