Files
beall/node_modules/@11ty/eleventy/src/Util/ArrayUtil.js

25 lines
398 B
JavaScript
Raw Normal View History

2026-03-31 16:38:22 -07:00
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;
}