@11ty/eleventy
Version:
A simpler static site generator.
25 lines (21 loc) • 398 B
JavaScript
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;
}