first
This commit is contained in:
24
node_modules/@11ty/eleventy/src/Util/ArrayUtil.js
generated
vendored
Normal file
24
node_modules/@11ty/eleventy/src/Util/ArrayUtil.js
generated
vendored
Normal file
@ -0,0 +1,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;
|
||||
}
|
||||
Reference in New Issue
Block a user