blob: bcb61deef9efed48020a5e7087881d4213244c6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
export function arrayDelete(arr, match) {
if (!Array.isArray(arr)) {
return [];
}
if (!match) {
return arr;
}
// only mutates if found
if (typeof match === "function") {
if (arr.find(match)) {
return arr.filter((entry) => {
return !match(entry);
});
}
} else if (arr.includes(match)) {
return arr.filter((entry) => {
return entry !== match;
});
}
return arr;
}
|