mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
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>
This commit is contained in:
parent
3cc65e925e
commit
392dc8e92b
15
types/find-replace/find-replace-tests.ts
Normal file
15
types/find-replace/find-replace-tests.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import findReplace = require("find-replace");
|
||||
|
||||
const numbers = [1, 2, 3, 4, 5];
|
||||
const resultTyped = findReplace<number>(
|
||||
numbers,
|
||||
num => num === 3,
|
||||
num => num * 2
|
||||
);
|
||||
|
||||
const colours = ['red', 'white', 'blue', 'white'];
|
||||
const resultAny = findReplace(
|
||||
colours,
|
||||
colour => colour === 'red',
|
||||
(colour: any) => colour.split('')
|
||||
);
|
||||
24
types/find-replace/index.d.ts
vendored
Normal file
24
types/find-replace/index.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// 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;
|
||||
23
types/find-replace/tsconfig.json
Normal file
23
types/find-replace/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"find-replace-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/find-replace/tslint.json
Normal file
1
types/find-replace/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user