mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 05:20:24 +08:00
Ramda: Make partial and partialRight binary fns
Change Added to Ramda 0.18.0 Pull Request: https://github.com/ramda/ramda/pull/1433 Upgrade guide: https://github.com/ramda/ramda/issues/1436
This commit is contained in:
20
types/ramda/index.d.ts
vendored
20
types/ramda/index.d.ts
vendored
@@ -10,6 +10,7 @@
|
||||
// Simon Højberg <https://github.com/hojberg>
|
||||
// Charles-Philippe Clermont <https://github.com/charlespwd>
|
||||
// Samson Keung <https://github.com/samsonkeung>
|
||||
// Angelo Ocana <https://github.com/angeloocana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -1196,19 +1197,20 @@ declare namespace R {
|
||||
pair<F, S>(fst: F, snd: S): [F, S];
|
||||
|
||||
/**
|
||||
* Accepts as its arguments a function and any number of values and returns a function that,
|
||||
* when invoked, calls the original function with all of the values prepended to the
|
||||
* original function's arguments list. In some libraries this function is named `applyLeft`.
|
||||
* Takes a function `f` and a list of arguments, and returns a function `g`.
|
||||
* When applied, `g` returns the result of applying `f` to the arguments
|
||||
* provided initially followed by the arguments provided to `g`.
|
||||
*/
|
||||
partial(fn: (...a: any[]) => any, ...args: any[]): (...a: any[]) => any;
|
||||
partial<T>(fn: (...a: any[]) => T, ...args: any[]): (...a: any[]) => T;
|
||||
partial(fn: (...a: any[]) => any, args: any[]): (...a: any[]) => any;
|
||||
partial<T>(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T;
|
||||
|
||||
/**
|
||||
* Accepts as its arguments a function and any number of values and returns a function that,
|
||||
* when invoked, calls the original function with all of the values appended to the original
|
||||
* function's arguments list.
|
||||
* Takes a function `f` and a list of arguments, and returns a function `g`.
|
||||
* When applied, `g` returns the result of applying `f` to the arguments
|
||||
* provided to `g` followed by the arguments provided initially.
|
||||
*/
|
||||
partialRight(fn: (...a: any[]) => any, ...args: any[]): (...a: any[]) => any;
|
||||
partialRight(fn: (...a: any[]) => any, args: any[]): (...a: any[]) => any;
|
||||
partialRight<T>(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T;
|
||||
|
||||
/**
|
||||
* Takes a predicate and a list and returns the pair of lists of elements
|
||||
|
||||
@@ -266,18 +266,18 @@ R.times(i, 5);
|
||||
return a * b;
|
||||
}
|
||||
|
||||
const double = R.partial<number>(multiply, 2);
|
||||
const double = R.partial<number>(multiply, [2]);
|
||||
double(2); // => 4
|
||||
|
||||
function greet(salutation: string, title: string, firstName: string, lastName: string) {
|
||||
return `${salutation}, ${title} ${firstName} ${lastName}!`;
|
||||
}
|
||||
|
||||
const sayHello = R.partial(greet, "Hello");
|
||||
const sayHelloToMs = R.partial(sayHello, "Ms.");
|
||||
const sayHello = R.partial(greet, ["Hello"]);
|
||||
const sayHelloToMs = R.partial(sayHello, ["Ms."]);
|
||||
sayHelloToMs("Jane", "Jones"); // => 'Hello, Ms. Jane Jones!'
|
||||
|
||||
const greetMsJaneJones = R.partialRight(greet, "Ms.", "Jane", "Jones");
|
||||
const greetMsJaneJones = R.partialRight(greet, ["Ms.", "Jane", "Jones"]);
|
||||
greetMsJaneJones("Hello"); // => 'Hello, Ms. Jane Jones!'
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user