es-toolkit 1.13.1-dev.377 → 1.13.1-dev.379
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/ary.d.mts +11 -0
- package/dist/compat/function/ary.d.ts +11 -0
- package/dist/compat/function/ary.mjs +13 -0
- package/dist/compat/index.d.mts +2 -1
- package/dist/compat/index.d.ts +2 -1
- package/dist/compat/index.js +12 -1
- package/dist/compat/index.mjs +2 -1
- package/dist/function/ary.d.mts +1 -2
- package/dist/function/ary.d.ts +1 -2
- package/dist/function/ary.mjs +2 -6
- package/dist/function/index.js +4 -8
- package/dist/function/unary.d.mts +1 -1
- package/dist/function/unary.d.ts +1 -1
- package/dist/function/unary.mjs +2 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +5 -0
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isBoolean.d.mts +25 -0
- package/dist/predicate/isBoolean.d.ts +25 -0
- package/dist/predicate/isBoolean.mjs +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
|
|
3
|
+
*
|
|
4
|
+
* @template F - The type of the function.
|
|
5
|
+
* @param {F} func - The function to cap arguments for.
|
|
6
|
+
* @param {number} n - The arity cap.
|
|
7
|
+
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
8
|
+
*/
|
|
9
|
+
declare function ary<F extends (...args: any[]) => any>(func: F, n?: number, guard?: unknown): ((...args: any[]) => ReturnType<F>);
|
|
10
|
+
|
|
11
|
+
export { ary };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
|
|
3
|
+
*
|
|
4
|
+
* @template F - The type of the function.
|
|
5
|
+
* @param {F} func - The function to cap arguments for.
|
|
6
|
+
* @param {number} n - The arity cap.
|
|
7
|
+
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
8
|
+
*/
|
|
9
|
+
declare function ary<F extends (...args: any[]) => any>(func: F, n?: number, guard?: unknown): ((...args: any[]) => ReturnType<F>);
|
|
10
|
+
|
|
11
|
+
export { ary };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -55,7 +55,6 @@ export { noop } from '../function/noop.mjs';
|
|
|
55
55
|
export { once } from '../function/once.mjs';
|
|
56
56
|
export { throttle } from '../function/throttle.mjs';
|
|
57
57
|
export { negate } from '../function/negate.mjs';
|
|
58
|
-
export { ary } from '../function/ary.mjs';
|
|
59
58
|
export { unary } from '../function/unary.mjs';
|
|
60
59
|
export { bind } from '../function/bind.mjs';
|
|
61
60
|
export { clamp } from '../math/clamp.mjs';
|
|
@@ -88,6 +87,7 @@ export { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
|
88
87
|
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
89
88
|
export { isObjectLike } from '../predicate/isObjectLike.mjs';
|
|
90
89
|
export { isArguments } from '../predicate/isArguments.mjs';
|
|
90
|
+
export { isBoolean } from '../predicate/isBoolean.mjs';
|
|
91
91
|
export { delay } from '../promise/delay.mjs';
|
|
92
92
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
93
93
|
export { camelCase } from '../string/camelCase.mjs';
|
|
@@ -105,6 +105,7 @@ export { flatten } from './array/flatten.mjs';
|
|
|
105
105
|
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
106
106
|
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
107
107
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
108
|
+
export { ary } from './function/ary.mjs';
|
|
108
109
|
export { get } from './object/get.mjs';
|
|
109
110
|
export { set } from './object/set.mjs';
|
|
110
111
|
export { property } from './object/property.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -55,7 +55,6 @@ export { noop } from '../function/noop.js';
|
|
|
55
55
|
export { once } from '../function/once.js';
|
|
56
56
|
export { throttle } from '../function/throttle.js';
|
|
57
57
|
export { negate } from '../function/negate.js';
|
|
58
|
-
export { ary } from '../function/ary.js';
|
|
59
58
|
export { unary } from '../function/unary.js';
|
|
60
59
|
export { bind } from '../function/bind.js';
|
|
61
60
|
export { clamp } from '../math/clamp.js';
|
|
@@ -88,6 +87,7 @@ export { isArrayLike } from '../predicate/isArrayLike.js';
|
|
|
88
87
|
export { isPrimitive } from '../predicate/isPrimitive.js';
|
|
89
88
|
export { isObjectLike } from '../predicate/isObjectLike.js';
|
|
90
89
|
export { isArguments } from '../predicate/isArguments.js';
|
|
90
|
+
export { isBoolean } from '../predicate/isBoolean.js';
|
|
91
91
|
export { delay } from '../promise/delay.js';
|
|
92
92
|
export { withTimeout } from '../promise/withTimeout.js';
|
|
93
93
|
export { camelCase } from '../string/camelCase.js';
|
|
@@ -105,6 +105,7 @@ export { flatten } from './array/flatten.js';
|
|
|
105
105
|
export { flattenDeep } from './array/flattenDeep.js';
|
|
106
106
|
export { flattenDepth } from './array/flattenDepth.js';
|
|
107
107
|
export { zipObjectDeep } from './array/zipObjectDeep.js';
|
|
108
|
+
export { ary } from './function/ary.js';
|
|
108
109
|
export { get } from './object/get.js';
|
|
109
110
|
export { set } from './object/set.js';
|
|
110
111
|
export { property } from './object/property.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -165,6 +165,16 @@ function zipObjectDeep(keys, values) {
|
|
|
165
165
|
return result;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
function ary(func, n = func.length, guard) {
|
|
169
|
+
if (guard) {
|
|
170
|
+
n = func.length;
|
|
171
|
+
}
|
|
172
|
+
if (Number.isNaN(n) || n < 0) {
|
|
173
|
+
n = 0;
|
|
174
|
+
}
|
|
175
|
+
return function_index.ary(func, n);
|
|
176
|
+
}
|
|
177
|
+
|
|
168
178
|
const IS_PLAIN = /^\w*$/;
|
|
169
179
|
const IS_DEEP = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
170
180
|
function isDeepKey(key) {
|
|
@@ -460,7 +470,6 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
460
470
|
exports.delay = promise_index.delay;
|
|
461
471
|
exports.withTimeout = promise_index.withTimeout;
|
|
462
472
|
exports.after = function_index.after;
|
|
463
|
-
exports.ary = function_index.ary;
|
|
464
473
|
exports.before = function_index.before;
|
|
465
474
|
exports.bind = function_index.bind;
|
|
466
475
|
exports.debounce = function_index.debounce;
|
|
@@ -490,6 +499,7 @@ exports.pick = object_index.pick;
|
|
|
490
499
|
exports.pickBy = object_index.pickBy;
|
|
491
500
|
exports.isArguments = predicate_index.isArguments;
|
|
492
501
|
exports.isArrayLike = predicate_index.isArrayLike;
|
|
502
|
+
exports.isBoolean = predicate_index.isBoolean;
|
|
493
503
|
exports.isEqual = predicate_index.isEqual;
|
|
494
504
|
exports.isFunction = predicate_index.isFunction;
|
|
495
505
|
exports.isLength = predicate_index.isLength;
|
|
@@ -506,6 +516,7 @@ exports.lowerCase = string_index.lowerCase;
|
|
|
506
516
|
exports.padStart = string_index.padStart;
|
|
507
517
|
exports.snakeCase = string_index.snakeCase;
|
|
508
518
|
exports.startCase = string_index.startCase;
|
|
519
|
+
exports.ary = ary;
|
|
509
520
|
exports.chunk = chunk;
|
|
510
521
|
exports.concat = concat;
|
|
511
522
|
exports.difference = difference;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -55,7 +55,6 @@ export { noop } from '../function/noop.mjs';
|
|
|
55
55
|
export { once } from '../function/once.mjs';
|
|
56
56
|
export { throttle } from '../function/throttle.mjs';
|
|
57
57
|
export { negate } from '../function/negate.mjs';
|
|
58
|
-
export { ary } from '../function/ary.mjs';
|
|
59
58
|
export { unary } from '../function/unary.mjs';
|
|
60
59
|
export { bind } from '../function/bind.mjs';
|
|
61
60
|
export { clamp } from '../math/clamp.mjs';
|
|
@@ -88,6 +87,7 @@ export { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
|
88
87
|
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
89
88
|
export { isObjectLike } from '../predicate/isObjectLike.mjs';
|
|
90
89
|
export { isArguments } from '../predicate/isArguments.mjs';
|
|
90
|
+
export { isBoolean } from '../predicate/isBoolean.mjs';
|
|
91
91
|
export { delay } from '../promise/delay.mjs';
|
|
92
92
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
93
93
|
export { camelCase } from '../string/camelCase.mjs';
|
|
@@ -105,6 +105,7 @@ export { flatten } from './array/flatten.mjs';
|
|
|
105
105
|
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
106
106
|
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
107
107
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
108
|
+
export { ary } from './function/ary.mjs';
|
|
108
109
|
export { get } from './object/get.mjs';
|
|
109
110
|
export { set } from './object/set.mjs';
|
|
110
111
|
export { property } from './object/property.mjs';
|
package/dist/function/ary.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
4
|
* @template F - The type of the function.
|
|
6
5
|
* @param {F} func - The function to cap arguments for.
|
|
7
6
|
* @param {number} n - The arity cap.
|
|
8
7
|
* @param {any} guard - Enables use as an iteratee for methods like `map`.
|
|
9
8
|
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
10
9
|
*/
|
|
11
|
-
declare
|
|
10
|
+
declare function ary<F extends (...args: any[]) => any>(func: F, n: number): ((...args: any[]) => ReturnType<F>);
|
|
12
11
|
|
|
13
12
|
export { ary };
|
package/dist/function/ary.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
4
|
* @template F - The type of the function.
|
|
6
5
|
* @param {F} func - The function to cap arguments for.
|
|
7
6
|
* @param {number} n - The arity cap.
|
|
8
7
|
* @param {any} guard - Enables use as an iteratee for methods like `map`.
|
|
9
8
|
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
10
9
|
*/
|
|
11
|
-
declare
|
|
10
|
+
declare function ary<F extends (...args: any[]) => any>(func: F, n: number): ((...args: any[]) => ReturnType<F>);
|
|
12
11
|
|
|
13
12
|
export { ary };
|
package/dist/function/ary.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
n = guard ? func.length : Number.parseInt(n.toString());
|
|
3
|
-
if (Number.isNaN(n) || n < 0) {
|
|
4
|
-
n = 0;
|
|
5
|
-
}
|
|
1
|
+
function ary(func, n) {
|
|
6
2
|
return function (...args) {
|
|
7
3
|
return func.apply(this, args.slice(0, n));
|
|
8
4
|
};
|
|
9
|
-
}
|
|
5
|
+
}
|
|
10
6
|
|
|
11
7
|
export { ary };
|
package/dist/function/index.js
CHANGED
|
@@ -87,19 +87,15 @@ function negate(func) {
|
|
|
87
87
|
return ((...args) => !func(...args));
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
n = guard ? func.length : Number.parseInt(n.toString());
|
|
92
|
-
if (Number.isNaN(n) || n < 0) {
|
|
93
|
-
n = 0;
|
|
94
|
-
}
|
|
90
|
+
function ary(func, n) {
|
|
95
91
|
return function (...args) {
|
|
96
92
|
return func.apply(this, args.slice(0, n));
|
|
97
93
|
};
|
|
98
|
-
}
|
|
94
|
+
}
|
|
99
95
|
|
|
100
|
-
|
|
96
|
+
function unary(func) {
|
|
101
97
|
return ary(func, 1);
|
|
102
|
-
}
|
|
98
|
+
}
|
|
103
99
|
|
|
104
100
|
function bind(func, thisArg, ...partials) {
|
|
105
101
|
const wrapper = function (...args) {
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* @param {F} func - The function to cap arguments for.
|
|
6
6
|
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
7
7
|
*/
|
|
8
|
-
declare
|
|
8
|
+
declare function unary<F extends (...args: any[]) => any>(func: F): ((...args: any[]) => ReturnType<F>);
|
|
9
9
|
|
|
10
10
|
export { unary };
|
package/dist/function/unary.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* @param {F} func - The function to cap arguments for.
|
|
6
6
|
* @returns {(...args: any[]) => ReturnType<F>} Returns the new capped function.
|
|
7
7
|
*/
|
|
8
|
-
declare
|
|
8
|
+
declare function unary<F extends (...args: any[]) => any>(func: F): ((...args: any[]) => ReturnType<F>);
|
|
9
9
|
|
|
10
10
|
export { unary };
|
package/dist/function/unary.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -96,6 +96,7 @@ export { isTypedArray } from './predicate/isTypedArray.mjs';
|
|
|
96
96
|
export { isPrimitive } from './predicate/isPrimitive.mjs';
|
|
97
97
|
export { isObjectLike } from './predicate/isObjectLike.mjs';
|
|
98
98
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
99
|
+
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
99
100
|
export { delay } from './promise/delay.mjs';
|
|
100
101
|
export { withTimeout } from './promise/withTimeout.mjs';
|
|
101
102
|
export { camelCase } from './string/camelCase.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export { isTypedArray } from './predicate/isTypedArray.js';
|
|
|
96
96
|
export { isPrimitive } from './predicate/isPrimitive.js';
|
|
97
97
|
export { isObjectLike } from './predicate/isObjectLike.js';
|
|
98
98
|
export { isArguments } from './predicate/isArguments.js';
|
|
99
|
+
export { isBoolean } from './predicate/isBoolean.js';
|
|
99
100
|
export { delay } from './promise/delay.js';
|
|
100
101
|
export { withTimeout } from './promise/withTimeout.js';
|
|
101
102
|
export { camelCase } from './string/camelCase.js';
|
package/dist/index.js
CHANGED
|
@@ -105,6 +105,7 @@ exports.pick = object_index.pick;
|
|
|
105
105
|
exports.pickBy = object_index.pickBy;
|
|
106
106
|
exports.isArguments = predicate_index.isArguments;
|
|
107
107
|
exports.isArrayLike = predicate_index.isArrayLike;
|
|
108
|
+
exports.isBoolean = predicate_index.isBoolean;
|
|
108
109
|
exports.isEqual = predicate_index.isEqual;
|
|
109
110
|
exports.isFunction = predicate_index.isFunction;
|
|
110
111
|
exports.isLength = predicate_index.isLength;
|
package/dist/index.mjs
CHANGED
|
@@ -96,6 +96,7 @@ export { isTypedArray } from './predicate/isTypedArray.mjs';
|
|
|
96
96
|
export { isPrimitive } from './predicate/isPrimitive.mjs';
|
|
97
97
|
export { isObjectLike } from './predicate/isObjectLike.mjs';
|
|
98
98
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
99
|
+
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
99
100
|
export { delay } from './promise/delay.mjs';
|
|
100
101
|
export { withTimeout } from './promise/withTimeout.mjs';
|
|
101
102
|
export { camelCase } from './string/camelCase.mjs';
|
package/dist/predicate/index.js
CHANGED
|
@@ -252,12 +252,17 @@ function isArguments(value) {
|
|
|
252
252
|
return value !== null && typeof value === 'object' && getTag(value) === '[object Arguments]';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
function isBoolean(x) {
|
|
256
|
+
return x === false || x === true || (x !== null && typeof x === 'object' && getTag(x) === '[object Boolean]');
|
|
257
|
+
}
|
|
258
|
+
|
|
255
259
|
exports.isPlainObject = isTypedArray.isPlainObject;
|
|
256
260
|
exports.isPrimitive = isTypedArray.isPrimitive;
|
|
257
261
|
exports.isTypedArray = isTypedArray.isTypedArray;
|
|
258
262
|
exports.isNil = isNil.isNil;
|
|
259
263
|
exports.isArguments = isArguments;
|
|
260
264
|
exports.isArrayLike = isArrayLike;
|
|
265
|
+
exports.isBoolean = isBoolean;
|
|
261
266
|
exports.isEqual = isEqual;
|
|
262
267
|
exports.isFunction = isFunction;
|
|
263
268
|
exports.isLength = isLength;
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is boolean.
|
|
3
|
+
*
|
|
4
|
+
* This function tests whether the provided value is strictly `boolean`.
|
|
5
|
+
* It returns `true` if the value is `boolean`, and `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} x - The Value to test if it is boolean.
|
|
10
|
+
* @returns {x is boolean} True if the value is booelan, false otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* const value1 = true;
|
|
15
|
+
* const value2 = 0;
|
|
16
|
+
* const value3 = 'abc';
|
|
17
|
+
*
|
|
18
|
+
* console.log(isBoolean(value1)); // true
|
|
19
|
+
* console.log(isBoolean(value2)); // false
|
|
20
|
+
* console.log(isBoolean(value3)); // false
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
declare function isBoolean(x: unknown): x is boolean;
|
|
24
|
+
|
|
25
|
+
export { isBoolean };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is boolean.
|
|
3
|
+
*
|
|
4
|
+
* This function tests whether the provided value is strictly `boolean`.
|
|
5
|
+
* It returns `true` if the value is `boolean`, and `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} x - The Value to test if it is boolean.
|
|
10
|
+
* @returns {x is boolean} True if the value is booelan, false otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* const value1 = true;
|
|
15
|
+
* const value2 = 0;
|
|
16
|
+
* const value3 = 'abc';
|
|
17
|
+
*
|
|
18
|
+
* console.log(isBoolean(value1)); // true
|
|
19
|
+
* console.log(isBoolean(value2)); // false
|
|
20
|
+
* console.log(isBoolean(value3)); // false
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
declare function isBoolean(x: unknown): x is boolean;
|
|
24
|
+
|
|
25
|
+
export { isBoolean };
|
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.13.1-dev.
|
|
4
|
+
"version": "1.13.1-dev.379+71dcaa4d",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|