Added a fallback Array.prototype.flat implementation (#935)
Fixes #647. Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>pull/937/head
parent
1efc99f87e
commit
42807da91f
|
@ -1,3 +1,5 @@
|
|||
import './compatibility'
|
||||
|
||||
// Import Vue
|
||||
import Vue from 'vue'
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
if (!Array.prototype.flat) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.flat = function (depth = 1) {
|
||||
return this.reduce(function (flat, toFlatten) {
|
||||
return flat.concat((Array.isArray(toFlatten) && (depth > 1)) ? toFlatten.flat(depth - 1) : toFlatten)
|
||||
}, [])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue