mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add R.replace that uses a replacer function
This commit is contained in:
6
types/ramda/index.d.ts
vendored
6
types/ramda/index.d.ts
vendored
@@ -2257,9 +2257,9 @@ declare namespace R {
|
||||
/**
|
||||
* Replace a substring or regex match in a string with a replacement.
|
||||
*/
|
||||
replace(pattern: RegExp | string, replacement: string, str: string): string;
|
||||
replace(pattern: RegExp | string, replacement: string): (str: string) => string;
|
||||
replace(pattern: RegExp | string): (replacement: string) => (str: string) => string;
|
||||
replace(pattern: RegExp | string, replacement: string | ((match: string, ...args: any[]) => string), str: string): string;
|
||||
replace(pattern: RegExp | string, replacement: string | ((match: string, ...args: any[]) => string)): (str: string) => string;
|
||||
replace(pattern: RegExp | string): (replacement: string | ((match: string, ...args: any[]) => string)) => (str: string) => string;
|
||||
|
||||
/**
|
||||
* Returns a new list with the same elements as the original list, just in the reverse order.
|
||||
|
||||
@@ -2569,6 +2569,11 @@ class Rectangle {
|
||||
R.replace(/foo/g, "bar", "foo foo foo"); // => 'bar bar bar'
|
||||
R.replace(/foo/g, "bar")("foo foo foo"); // => 'bar bar bar'
|
||||
R.replace(/foo/g)("bar")("foo foo foo"); // => 'bar bar bar'
|
||||
|
||||
// Using a function as the replacement value
|
||||
R.replace(/([cfk])oo/g, (match, p1, offset) => `${p1}-${offset}`, "coo foo koo"); // => 'c0oo f4oo k8oo'
|
||||
R.replace(/([cfk])oo/g, (match, p1, offset) => `${p1}-${offset}`)("coo foo koo"); // => 'c0oo f4oo k8oo'
|
||||
R.replace(/([cfk])oo/g)((match, p1, offset) => `${p1}-${offset}`) ("coo foo koo"); // => 'c0oo f4oo k8oo'
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
|
||||
Reference in New Issue
Block a user