-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.js
46 lines (37 loc) · 1.28 KB
/
util.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
define(function () {
function extend(target, source) {
source = source || {};
for (var k in source) {
if (!target.hasOwnProperty(k)) {
target[k] = source[k];
}
}
}
return {
augment: function (target, source) {
var k;
for (k in source) {
if (source.hasOwnProperty(k)) {
Object.defineProperty(target, k, Object.getOwnPropertyDescriptor(source, k));
}
}
},
// core.DOMException.prototype.__proto__ = Error.prototype;
inherit: function (ctor, base, props) {
var descriptors = {};
var k;
for (k in props) {
if (props.hasOwnProperty(k)) {
descriptors[k] = Object.getOwnPropertyDescriptor(props, k);
}
}
ctor.prototype = Object.create(base, descriptors);
ctor.prototype.constructor = ctor;
},
updateProperty: function (obj, prop, descriptor) {
extend(descriptor, Object.getOwnPropertyDescriptor(obj, prop));
extend(descriptor, { enumerable: true, configurable: true });
Object.defineProperty(obj, prop, descriptor);
}
};
});