forked from aaditmshah/augment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaugment.js
More file actions
35 lines (30 loc) · 1.21 KB
/
augment.js
File metadata and controls
35 lines (30 loc) · 1.21 KB
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
(function (global, factory) {
if (typeof define === "function" && define.amd) define(factory);
else if (typeof module === "object") module.exports = factory();
else global.augment = factory();
}(this, function () {
"use strict";
var Factory = function () {};
var slice = Array.prototype.slice;
var augment = function (base, body) {
var uber = Factory.prototype = typeof base === "function" ? base.prototype : base;
var prototype = new Factory, properties = body.apply(prototype, slice.call(arguments, 2).concat(uber));
if (typeof properties === "object") for (var key in properties) prototype[key] = properties[key];
if (!prototype.hasOwnProperty("constructor")) return prototype;
var constructor = prototype.constructor;
constructor.prototype = prototype;
return constructor;
};
augment.defclass = function (prototype) {
var constructor = prototype.constructor;
constructor.prototype = prototype;
return constructor;
};
augment.extend = function (base, body) {
return augment(base, function (uber) {
this.uber = uber;
return body;
});
};
return augment;
}));