|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Returns the provided function as-is when it is a function type.
|
|---|
| 3 | *
|
|---|
| 4 | * @template F - The function type
|
|---|
| 5 | * @param {F} func - The function to return
|
|---|
| 6 | * @returns {F} Returns the provided function unchanged
|
|---|
| 7 | *
|
|---|
| 8 | * @example
|
|---|
| 9 | * const fn = (x: number) => x * 2;
|
|---|
| 10 | * const iterateeFn = iteratee(fn);
|
|---|
| 11 | * iterateeFn(4); // => 8
|
|---|
| 12 | */
|
|---|
| 13 | declare function iteratee<F extends (...args: any[]) => any>(func: F): F;
|
|---|
| 14 | /**
|
|---|
| 15 | * Creates an iteratee function based on the provided property key or object.
|
|---|
| 16 | * If given a property key, returns a function that gets that property from objects.
|
|---|
| 17 | * If given an object, returns a function that matches objects against the provided one.
|
|---|
| 18 | *
|
|---|
| 19 | * @param {PropertyKey | object} func - The value to convert to an iteratee
|
|---|
| 20 | * @returns {Function} Returns the iteratee function
|
|---|
| 21 | *
|
|---|
| 22 | * @example
|
|---|
| 23 | * // With property key
|
|---|
| 24 | * const getLength = iteratee('length');
|
|---|
| 25 | * getLength([1,2,3]); // => 3
|
|---|
| 26 | *
|
|---|
| 27 | * // With object
|
|---|
| 28 | * const matchObj = iteratee({ x: 1, y: 2 });
|
|---|
| 29 | * matchObj({ x: 1, y: 2, z: 3 }); // => true
|
|---|
| 30 | */
|
|---|
| 31 | declare function iteratee(func: PropertyKey | object): (...args: any[]) => any;
|
|---|
| 32 |
|
|---|
| 33 | export { iteratee };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.