Added a fallback Array.prototype.flat implementation (#935)

Fixes #647.

Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
pull/937/head
Boris Krivonog 2021-03-06 01:14:18 +01:00 committed by GitHub
parent 1efc99f87e
commit 42807da91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import './compatibility'
// Import Vue
import Vue from 'vue'

View File

@ -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)
}, [])
}
}