forked from tsai/budibase
2 changed files with 2 additions and 37 deletions
@ -1,26 +0,0 @@ |
|||||
// Array.flat needs polyfilled in < Node 11
|
|
||||
if (!Array.prototype.flat) { |
|
||||
Object.defineProperty(Array.prototype, "flat", { |
|
||||
configurable: true, |
|
||||
value: function flat() { |
|
||||
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]) |
|
||||
|
|
||||
return depth |
|
||||
? Array.prototype.reduce.call( |
|
||||
this, |
|
||||
function(acc, cur) { |
|
||||
if (Array.isArray(cur)) { |
|
||||
acc.push.apply(acc, flat.call(cur, depth - 1)) |
|
||||
} else { |
|
||||
acc.push(cur) |
|
||||
} |
|
||||
|
|
||||
return acc |
|
||||
}, |
|
||||
[] |
|
||||
) |
|
||||
: Array.prototype.slice.call(this) |
|
||||
}, |
|
||||
writable: true, |
|
||||
}) |
|
||||
} |
|
||||
Loading…
Reference in new issue