-
Notifications
You must be signed in to change notification settings - Fork 0
/
polyfill.ts
45 lines (41 loc) · 1.08 KB
/
polyfill.ts
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
interface ObjectConstructor {
assign(target: any, ...sources: any[]): any;
values(target: any): any;
}
interface Array<T> {
find(predicate: (search: T) => boolean): T;
}
if (typeof Object.assign !== "function") {
(function() {
Object.assign = function(target) {
if (target === undefined || target === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
let output = Object(target);
for (let index = 1; index < arguments.length; index++) {
let source = arguments[index];
if (source !== undefined && source !== null) {
for (let nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}
return output;
};
})();
}
if (typeof Object.values !== "function") {
(function() {
Object.values = function(target) {
let vals = [];
for (let key in target) {
if (target.hasOwnProperty(key)) {
vals.push(target[key]);
}
}
return vals;
};
})();
}