update invoker function signature

This commit is contained in:
Rayner Pupo
2017-12-19 22:31:24 -05:00
parent f87e32cec6
commit 18ebf4d5f8
2 changed files with 8 additions and 9 deletions

View File

@@ -11,6 +11,7 @@
// Charles-Philippe Clermont <https://github.com/charlespwd>
// Samson Keung <https://github.com/samsonkeung>
// Angelo Ocana <https://github.com/angeloocana>
// Rayner Pupo <https://github.com/raynerd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -812,15 +813,13 @@ declare namespace R {
invertObj(obj: { [index: string]: string } | { [index: number]: string }): { [index: string]: string };
/**
* Turns a named method of an object (or object prototype) into a function that can be
* called directly. Passing the optional `len` parameter restricts the returned function to
* the initial `len` parameters of the method.
* Turns a named method with a specified arity into a function that can be called directly
* supplied with arguments and a target object.
*
* The returned function is curried and accepts `len + 1` parameters (or `method.length + 1`
* when `len` is not specified), and the final parameter is the target object.
* The returned function is curried and accepts `arity + 1` parameters where the final
* parameter is the target object.
*/
invoker(name: string, obj: any, len?: number): (...a: any[]) => any;
invoker(name: string): (obj: any, len?: number) => (...a: any[]) => any;
invoker(arity: number, method: string): (...a: any[]) => any;
/**
* See if an object (`val`) is an instance of the supplied constructor.

View File

@@ -202,8 +202,8 @@ class F2 {
};
() => {
R.invoker("charAt", String.prototype);
R.invoker("charAt", String.prototype, 1);
R.invoker(1, "slice")(6, "abcdefghijklm");
R.invoker(2, "slice")(6)(8, "abcdefghijklm");
};
(() => {