es-toolkit 1.29.0-dev.948 → 1.29.0-dev.950
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/function/nthArg.d.mts +22 -0
- package/dist/compat/function/nthArg.d.ts +22 -0
- package/dist/compat/function/nthArg.mjs +9 -0
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +7 -0
- package/dist/compat/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that retrieves the argument at the specified index `n`.
|
|
3
|
+
*
|
|
4
|
+
* If `n` is negative, the nth argument from the end is returned.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} [n=0] - The index of the argument to retrieve.
|
|
7
|
+
* If negative, counts from the end of the arguments list.
|
|
8
|
+
* @returns {(args: any[]) => unknown} A new function that returns the argument at the specified index.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const getSecondArg = nthArg(1);
|
|
12
|
+
* const result = getSecondArg('a', 'b', 'c');
|
|
13
|
+
* console.log(result); // => 'b'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const getLastArg = nthArg(-1);
|
|
17
|
+
* const result = getLastArg('a', 'b', 'c');
|
|
18
|
+
* console.log(result); // => 'c'
|
|
19
|
+
*/
|
|
20
|
+
declare function nthArg(n?: number): (...args: any[]) => unknown;
|
|
21
|
+
|
|
22
|
+
export { nthArg };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that retrieves the argument at the specified index `n`.
|
|
3
|
+
*
|
|
4
|
+
* If `n` is negative, the nth argument from the end is returned.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} [n=0] - The index of the argument to retrieve.
|
|
7
|
+
* If negative, counts from the end of the arguments list.
|
|
8
|
+
* @returns {(args: any[]) => unknown} A new function that returns the argument at the specified index.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const getSecondArg = nthArg(1);
|
|
12
|
+
* const result = getSecondArg('a', 'b', 'c');
|
|
13
|
+
* console.log(result); // => 'b'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const getLastArg = nthArg(-1);
|
|
17
|
+
* const result = getLastArg('a', 'b', 'c');
|
|
18
|
+
* console.log(result); // => 'c'
|
|
19
|
+
*/
|
|
20
|
+
declare function nthArg(n?: number): (...args: any[]) => unknown;
|
|
21
|
+
|
|
22
|
+
export { nthArg };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -130,6 +130,7 @@ export { defer } from './function/defer.mjs';
|
|
|
130
130
|
export { flip } from './function/flip.mjs';
|
|
131
131
|
export { flow } from './function/flow.mjs';
|
|
132
132
|
export { flowRight } from './function/flowRight.mjs';
|
|
133
|
+
export { nthArg } from './function/nthArg.mjs';
|
|
133
134
|
export { rearg } from './function/rearg.mjs';
|
|
134
135
|
export { rest } from './function/rest.mjs';
|
|
135
136
|
export { spread } from './function/spread.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ export { defer } from './function/defer.js';
|
|
|
130
130
|
export { flip } from './function/flip.js';
|
|
131
131
|
export { flow } from './function/flow.js';
|
|
132
132
|
export { flowRight } from './function/flowRight.js';
|
|
133
|
+
export { nthArg } from './function/nthArg.js';
|
|
133
134
|
export { rearg } from './function/rearg.js';
|
|
134
135
|
export { rest } from './function/rest.js';
|
|
135
136
|
export { spread } from './function/spread.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1683,6 +1683,12 @@ function flowRight(...funcs) {
|
|
|
1683
1683
|
return unary.flowRight(...flattenFuncs);
|
|
1684
1684
|
}
|
|
1685
1685
|
|
|
1686
|
+
function nthArg(n = 0) {
|
|
1687
|
+
return function (...args) {
|
|
1688
|
+
return args.at(toInteger(n));
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1686
1692
|
function rearg(func, ...indices) {
|
|
1687
1693
|
const flattenIndices = flatten(indices);
|
|
1688
1694
|
return function (...args) {
|
|
@@ -3116,6 +3122,7 @@ exports.method = method;
|
|
|
3116
3122
|
exports.min = min;
|
|
3117
3123
|
exports.now = now;
|
|
3118
3124
|
exports.nth = nth;
|
|
3125
|
+
exports.nthArg = nthArg;
|
|
3119
3126
|
exports.omit = omit;
|
|
3120
3127
|
exports.orderBy = orderBy;
|
|
3121
3128
|
exports.pad = pad;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -132,6 +132,7 @@ export { defer } from './function/defer.mjs';
|
|
|
132
132
|
export { flip } from './function/flip.mjs';
|
|
133
133
|
export { flow } from './function/flow.mjs';
|
|
134
134
|
export { flowRight } from './function/flowRight.mjs';
|
|
135
|
+
export { nthArg } from './function/nthArg.mjs';
|
|
135
136
|
export { rearg } from './function/rearg.mjs';
|
|
136
137
|
export { rest } from './function/rest.mjs';
|
|
137
138
|
export { spread } from './function/spread.mjs';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.29.0-dev.
|
|
4
|
+
"version": "1.29.0-dev.950+77c3509b",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|