Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace flattenArray with build-in Array.flat function #806

Open
wants to merge 1 commit into
base: v3.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/animatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {

import {
is,
flattenArray,
filterArray,
arrayContains,
toArray,
Expand All @@ -32,7 +31,7 @@ function registerTarget(target) {
}

function parseTargets(targets) {
const targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
const targetsArray = targets ? (is.arr(targets) ? targets.map(toArray).flat() : toArray(targets).flat()) : [];
return filterArray(targetsArray, (item, pos, self) => self.indexOf(item) === pos);
}

Expand Down
3 changes: 1 addition & 2 deletions src/keyframes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
is,
mergeObjects,
flattenArray,
filterArray,
} from './utils.js';

Expand Down Expand Up @@ -52,7 +51,7 @@ function convertPropertyValueToTweens(propertyName, propertyValue, tweenSettings

function flattenParamsKeyframes(keyframes) {
const properties = {};
const propertyNames = filterArray(flattenArray(keyframes.map(key => Object.keys(key))), p => is.key(p))
const propertyNames = filterArray(keyframes.map((key) => Object.keys(key)).flat(), p => is.key(p))
.reduce((a,b) => {
if (a.indexOf(b) < 0) {
a.push(b);
Expand Down
4 changes: 0 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ export function filterArray(arr, callback) {
return result;
}

export function flattenArray(arr) {
return arr.reduce((a, b) => a.concat(is.arr(b) ? flattenArray(b) : b), []);
}

export function toArray(o) {
if (is.arr(o)) return o;
if (is.str(o)) o = selectString(o) || o;
Expand Down