Skip to content

Commit 66e31cc

Browse files
committed
feat: replace flattenArray with build-in Array.flat function
Signed-off-by: Tobias Kuppens Groot <[email protected]>
1 parent 55a3a47 commit 66e31cc

File tree

4 files changed

+2
-9
lines changed

4 files changed

+2
-9
lines changed

src/animatables.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44

55
import {
66
is,
7-
flattenArray,
87
filterArray,
98
toArray,
109
} from './helpers.js';
@@ -14,7 +13,7 @@ import {
1413
} from './values.js';
1514

1615
export function parseTargets(targets) {
17-
const targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
16+
const targetsArray = targets ? (is.arr(targets) ? targets.map(toArray).flat() : toArray(targets).flat()) : [];
1817
return filterArray(targetsArray, (item, pos, self) => self.indexOf(item) === pos);
1918
}
2019

src/anime.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
random,
99
is,
1010
filterArray,
11-
flattenArray,
1211
toArray,
1312
arrayContains,
1413
cloneObject,

src/helpers.js

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ export function filterArray(arr, callback) {
7272
return result;
7373
}
7474

75-
export function flattenArray(arr) {
76-
return arr.reduce((a, b) => a.concat(is.arr(b) ? flattenArray(b) : b), []);
77-
}
78-
7975
export function toArray(o) {
8076
if (is.arr(o)) return o;
8177
if (is.str(o)) o = selectString(o) || o;

src/keyframes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
is,
33
cloneObject,
44
mergeObjects,
5-
flattenArray,
65
filterArray,
76
} from './helpers.js';
87

@@ -52,7 +51,7 @@ function convertPropertyValueToTweens(propertyValue, tweenSettings) {
5251

5352
function flattenParamsKeyframes(keyframes) {
5453
const properties = {};
55-
const propertyNames = filterArray(flattenArray(keyframes.map(key => Object.keys(key))), p => is.key(p))
54+
const propertyNames = filterArray(keyframes.map((key) => Object.keys(key)).flat(), p => is.key(p))
5655
.reduce((a,b) => {
5756
if (a.indexOf(b) < 0) {
5857
a.push(b);

0 commit comments

Comments
 (0)