|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
699 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Creates a function that invokes the method at a given path of `object` with the provided arguments.
|
|---|
| 3 | *
|
|---|
| 4 | * @param {object} object - The object to query.
|
|---|
| 5 | * @param {...any} args - The arguments to invoke the method with.
|
|---|
| 6 | * @returns {(path: PropertyKey | PropertyKey[]) => any} - Returns a new function that takes a path and invokes the method at `path` with `args`.
|
|---|
| 7 | *
|
|---|
| 8 | * @example
|
|---|
| 9 | * const object = {
|
|---|
| 10 | * a: {
|
|---|
| 11 | * b: function (x, y) {
|
|---|
| 12 | * return x + y;
|
|---|
| 13 | * }
|
|---|
| 14 | * }
|
|---|
| 15 | * };
|
|---|
| 16 | *
|
|---|
| 17 | * const add = methodOf(object, 1, 2);
|
|---|
| 18 | * console.log(add('a.b')); // => 3
|
|---|
| 19 | */
|
|---|
| 20 | declare function methodOf(object: object, ...args: any[]): (path: PropertyKey | readonly PropertyKey[]) => any;
|
|---|
| 21 |
|
|---|
| 22 | export { methodOf };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.