Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey28 committed Sep 11, 2023
1 parent d33b833 commit 0559b91
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/client/core/utils/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,32 @@ export function isArray (arg) {
}

export function from (arg, ...args) {
return nativeMethods.arrayFrom(arg, ...args);
if (nativeMethods.arrayFrom)
return nativeMethods.arrayFrom(arg, ...args);

// NOTE: this logic is for IE
const arr = [];
const length = arg.length;

for (let i = 0; i < length; i++)
arr.push(arg[i]);

return arr;
}

export function find (arr, callback) {
return nativeMethods.arrayFind.call(arr, callback);
if (nativeMethods.arrayFind)
return nativeMethods.arrayFind.call(arr, callback);

// NOTE: this logic is for IE
const length = arr.length;

for (let i = 0; i < length; i++) {
if (callback(arr[i], i, arr))
return arr[i];
}

return null;
}

export function remove (arr, item) {
Expand Down

0 comments on commit 0559b91

Please sign in to comment.