DefinitelyTyped/types/find-replace/index.d.ts
Renat Zamaletdinov 392dc8e92b
find-replace types added (#44151)
* find-replace types added

* Files regenerated

* Update types/find-replace/index.d.ts

Co-Authored-By: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
2020-04-27 09:01:26 -04:00

25 lines
1.1 KiB
TypeScript

// Type definitions for find-replace 4.0
// Project: https://github.com/75lb/find-replace#readme
// Definitions by: Renat Zamaletdinov <https://github.com/Zamaletdinov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Replace or remove multiple items in an array
*
* `array` - The input array
*
* `findFn` - A predicate which, if returns true causes the current item to be operated on
*
* `...replaceWiths`:
*
* * If not specified, each found value will be removed.
* * If specified, each found value will be replaced with this value.
* * If the replaceWith value is a function, it will be invoked with the found value and its result used as the replace value.
* * If the replaceWith function returns an array, the found value will be replaced with each item in the array (not replaced with the array itself).
*/
declare function findReplace<T>(array: T[], findFn: (x: T) => boolean, ...replaceWiths: Array<T | ((x: T) => T)>): T[];
declare function findReplace(array: any[], findFn: (x: any) => boolean, ...replaceWiths: any[]): any[];
export as namespace findReplace;
export = findReplace;