UNPKG

@surveycake/utils

Version:

SurveyCake Javascript Utils

18 lines (17 loc) 621 B
/** * Remove specific item that equal data or finded by finder from source. * * @param finder A factory, data is second param, return a function just like `Array.find`. * * ```ts * removeItem([1, '2', true, { a: 1 }], 0) => [1, '2', true, { a: 1 }] * removeItem([1, '2', true, { a: 1 }], 1) => ['2', true, { a: 1 }] * ``` * * ```ts * removeItem([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], { a: 3 }, data => item => data.a === item.a) * => * [{ a: 1 }, { a: 2 }, { a: 4 }] * ``` */ export declare function removeItem<T>(source: T[], data: T, finder?: (data: T) => (item: T) => boolean): T[];