es-toolkit 1.13.1-dev.376 → 1.13.1-dev.378

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.
@@ -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 };
@@ -0,0 +1,13 @@
1
+ import { ary as ary$1 } from '../../function/ary.mjs';
2
+
3
+ function ary(func, n = func.length, guard) {
4
+ if (guard) {
5
+ n = func.length;
6
+ }
7
+ if (Number.isNaN(n) || n < 0) {
8
+ n = 0;
9
+ }
10
+ return ary$1(func, n);
11
+ }
12
+
13
+ export { ary };
@@ -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';
@@ -105,6 +104,7 @@ export { flatten } from './array/flatten.mjs';
105
104
  export { flattenDeep } from './array/flattenDeep.mjs';
106
105
  export { flattenDepth } from './array/flattenDepth.mjs';
107
106
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
107
+ export { ary } from './function/ary.mjs';
108
108
  export { get } from './object/get.mjs';
109
109
  export { set } from './object/set.mjs';
110
110
  export { property } from './object/property.mjs';
@@ -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';
@@ -105,6 +104,7 @@ export { flatten } from './array/flatten.js';
105
104
  export { flattenDeep } from './array/flattenDeep.js';
106
105
  export { flattenDepth } from './array/flattenDepth.js';
107
106
  export { zipObjectDeep } from './array/zipObjectDeep.js';
107
+ export { ary } from './function/ary.js';
108
108
  export { get } from './object/get.js';
109
109
  export { set } from './object/set.js';
110
110
  export { property } from './object/property.js';
@@ -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;
@@ -506,6 +515,7 @@ exports.lowerCase = string_index.lowerCase;
506
515
  exports.padStart = string_index.padStart;
507
516
  exports.snakeCase = string_index.snakeCase;
508
517
  exports.startCase = string_index.startCase;
518
+ exports.ary = ary;
509
519
  exports.chunk = chunk;
510
520
  exports.concat = concat;
511
521
  exports.difference = difference;
@@ -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';
@@ -105,6 +104,7 @@ export { flatten } from './array/flatten.mjs';
105
104
  export { flattenDeep } from './array/flattenDeep.mjs';
106
105
  export { flattenDepth } from './array/flattenDepth.mjs';
107
106
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
107
+ export { ary } from './function/ary.mjs';
108
108
  export { get } from './object/get.mjs';
109
109
  export { set } from './object/set.mjs';
110
110
  export { property } from './object/property.mjs';
@@ -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 const ary: <F extends (...args: any[]) => any>(func: F, n?: number, guard?: any) => ((...args: any[]) => ReturnType<F>);
10
+ declare function ary<F extends (...args: any[]) => any>(func: F, n: number): ((...args: any[]) => ReturnType<F>);
12
11
 
13
12
  export { ary };
@@ -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 const ary: <F extends (...args: any[]) => any>(func: F, n?: number, guard?: any) => ((...args: any[]) => ReturnType<F>);
10
+ declare function ary<F extends (...args: any[]) => any>(func: F, n: number): ((...args: any[]) => ReturnType<F>);
12
11
 
13
12
  export { ary };
@@ -1,11 +1,7 @@
1
- const ary = (func, n = func.length, guard) => {
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 };
@@ -87,19 +87,15 @@ function negate(func) {
87
87
  return ((...args) => !func(...args));
88
88
  }
89
89
 
90
- const ary = (func, n = func.length, guard) => {
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
- const unary = (func) => {
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 const unary: <F extends (...args: any[]) => any>(func: F) => ((...args: any[]) => ReturnType<F>);
8
+ declare function unary<F extends (...args: any[]) => any>(func: F): ((...args: any[]) => ReturnType<F>);
9
9
 
10
10
  export { unary };
@@ -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 const unary: <F extends (...args: any[]) => any>(func: F) => ((...args: any[]) => ReturnType<F>);
8
+ declare function unary<F extends (...args: any[]) => any>(func: F): ((...args: any[]) => ReturnType<F>);
9
9
 
10
10
  export { unary };
@@ -1,7 +1,7 @@
1
1
  import { ary } from './ary.mjs';
2
2
 
3
- const unary = (func) => {
3
+ function unary(func) {
4
4
  return ary(func, 1);
5
- };
5
+ }
6
6
 
7
7
  export { unary };
@@ -153,7 +153,7 @@ function areObjectsEqual(a, b, stack) {
153
153
  case bigInt64ArrayTag:
154
154
  case float32ArrayTag:
155
155
  case float64ArrayTag: {
156
- if (Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
156
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
157
157
  return false;
158
158
  }
159
159
  if (a.length !== b.length) {
@@ -112,7 +112,7 @@ function areObjectsEqual(a, b, stack) {
112
112
  case bigInt64ArrayTag:
113
113
  case float32ArrayTag:
114
114
  case float64ArrayTag: {
115
- if (Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
115
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
116
116
  return false;
117
117
  }
118
118
  if (a.length !== b.length) {
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.376+a816cb1f",
4
+ "version": "1.13.1-dev.378+b2427e1f",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {