mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 20:24:51 +08:00
17 lines
418 B
JavaScript
17 lines
418 B
JavaScript
|
|
||
|
Array.prototype.flat || Object.defineProperty(Array.prototype, 'flat', {
|
||
|
configurable: true,
|
||
|
value: function flat(depth) {
|
||
|
depth = isNaN(depth) ? 1 : Number(depth);
|
||
|
return depth ? Array.prototype.reduce.call(this, (acc, cur) => {
|
||
|
if (Array.isArray(cur)) {
|
||
|
acc.push.apply(acc, flat.call(cur, depth - 1));
|
||
|
} else {
|
||
|
acc.push(cur);
|
||
|
}
|
||
|
return acc;
|
||
|
}, []) : this.slice();
|
||
|
},
|
||
|
writable: true
|
||
|
});
|