|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
715 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Creates a function that invokes the method at `path` of a given object with the provided arguments.
|
|---|
| 3 | *
|
|---|
| 4 | * @param {PropertyKey | PropertyKey[]} path - The path of the method to invoke.
|
|---|
| 5 | * @param {...any} args - The arguments to invoke the method with.
|
|---|
| 6 | * @returns {(object?: unknown) => any} - Returns a new function that takes an object 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 = method('a.b', 1, 2);
|
|---|
| 18 | * console.log(add(object)); // => 3
|
|---|
| 19 | */
|
|---|
| 20 | declare function method(path: PropertyKey | readonly PropertyKey[], ...args: any[]): (object: any) => any;
|
|---|
| 21 |
|
|---|
| 22 | export { method };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.