typedash
Version:
modern, type-safe collection of utility functions
22 lines (20 loc) • 844 B
JavaScript
import { t as createTypeGuard } from "./createTypeGuard-DTvIg0I0.js";
//#region src/functions/without/without.ts
/**
* Returns a new array containing all elements of the input array except the specified items to exclude.
* @param array The input array to exclude items from.
* @param itemsToExclude An iterable of items to exclude from the input array.
* @returns A new array containing all elements of the input array except the specified items to exclude.
* @example
* ```ts
* without([1, 2, 3], [2, 3]) // [1]
* without(['a', 'b', 'c'], ['b', 'c']) // ['a']
* without([1, 2, 3], []) // [1, 2, 3]
*/
function without(array, itemsToExclude) {
const isItemToExclude = createTypeGuard(itemsToExclude);
return array.filter((item) => !isItemToExclude(item));
}
//#endregion
export { without as t };
//# sourceMappingURL=without-CwqZmdm4.js.map