es-toolkit 1.13.1-dev.367 → 1.13.1-dev.369

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.
@@ -40,6 +40,7 @@ export { zipObject } from '../array/zipObject.mjs';
40
40
  export { zipWith } from '../array/zipWith.mjs';
41
41
  export { without } from '../array/without.mjs';
42
42
  export { head as first, head } from '../array/head.mjs';
43
+ export { isSubset } from '../array/isSubset.mjs';
43
44
  export { tail } from '../array/tail.mjs';
44
45
  export { toFilled } from '../array/toFilled.mjs';
45
46
  export { last } from '../array/last.mjs';
@@ -54,6 +55,7 @@ export { noop } from '../function/noop.mjs';
54
55
  export { once } from '../function/once.mjs';
55
56
  export { throttle } from '../function/throttle.mjs';
56
57
  export { negate } from '../function/negate.mjs';
58
+ export { bind } from '../function/bind.mjs';
57
59
  export { clamp } from '../math/clamp.mjs';
58
60
  export { inRange } from '../math/inRange.mjs';
59
61
  export { mean } from '../math/mean.mjs';
@@ -40,6 +40,7 @@ export { zipObject } from '../array/zipObject.js';
40
40
  export { zipWith } from '../array/zipWith.js';
41
41
  export { without } from '../array/without.js';
42
42
  export { head as first, head } from '../array/head.js';
43
+ export { isSubset } from '../array/isSubset.js';
43
44
  export { tail } from '../array/tail.js';
44
45
  export { toFilled } from '../array/toFilled.js';
45
46
  export { last } from '../array/last.js';
@@ -54,6 +55,7 @@ export { noop } from '../function/noop.js';
54
55
  export { once } from '../function/once.js';
55
56
  export { throttle } from '../function/throttle.js';
56
57
  export { negate } from '../function/negate.js';
58
+ export { bind } from '../function/bind.js';
57
59
  export { clamp } from '../math/clamp.js';
58
60
  export { inRange } from '../math/inRange.js';
59
61
  export { mean } from '../math/mean.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const size = require('../_chunk/size-CJyNw8.js');
5
+ const size = require('../_chunk/size-DmGMC-.js');
6
6
  const isNil = require('../_chunk/isNil-IuJ4cv.js');
7
7
  const promise_index = require('../_chunk/index-CwRt_M.js');
8
8
  const function_index = require('../function/index.js');
@@ -423,6 +423,7 @@ exports.initial = size.initial;
423
423
  exports.intersection = size.intersection;
424
424
  exports.intersectionBy = size.intersectionBy;
425
425
  exports.intersectionWith = size.intersectionWith;
426
+ exports.isSubset = size.isSubset;
426
427
  exports.keyBy = size.keyBy;
427
428
  exports.last = size.last;
428
429
  exports.maxBy = size.maxBy;
@@ -461,6 +462,7 @@ exports.delay = promise_index.delay;
461
462
  exports.withTimeout = promise_index.withTimeout;
462
463
  exports.after = function_index.after;
463
464
  exports.before = function_index.before;
465
+ exports.bind = function_index.bind;
464
466
  exports.debounce = function_index.debounce;
465
467
  exports.negate = function_index.negate;
466
468
  exports.noop = function_index.noop;
@@ -40,6 +40,7 @@ export { zipObject } from '../array/zipObject.mjs';
40
40
  export { zipWith } from '../array/zipWith.mjs';
41
41
  export { without } from '../array/without.mjs';
42
42
  export { head as first, head } from '../array/head.mjs';
43
+ export { isSubset } from '../array/isSubset.mjs';
43
44
  export { tail } from '../array/tail.mjs';
44
45
  export { toFilled } from '../array/toFilled.mjs';
45
46
  export { last } from '../array/last.mjs';
@@ -54,6 +55,7 @@ export { noop } from '../function/noop.mjs';
54
55
  export { once } from '../function/once.mjs';
55
56
  export { throttle } from '../function/throttle.mjs';
56
57
  export { negate } from '../function/negate.mjs';
58
+ export { bind } from '../function/bind.mjs';
57
59
  export { clamp } from '../math/clamp.mjs';
58
60
  export { inRange } from '../math/inRange.mjs';
59
61
  export { mean } from '../math/mean.mjs';
@@ -0,0 +1,32 @@
1
+ /**
2
+ *
3
+ * Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives.
4
+ *
5
+ * The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
6
+ *
7
+ * **Note:** Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions.
8
+ *
9
+ * @param {(...args: any[]) => any} func The function to bind.
10
+ * @param {any} thisArg The `this` binding of `func`.
11
+ * @param {any[]} partials The arguments to be partially applied.
12
+ * @returns {(...args: any[]) => any} Returns the new bound function.
13
+ *
14
+ * @example
15
+ * function greet(greeting, punctuation) {
16
+ * return greeting + ' ' + this.user + punctuation;
17
+ * }
18
+ * const object = { user: 'fred' };
19
+ * let bound = bind(greet, object, 'hi');
20
+ * bound('!');
21
+ * // => 'hi fred!'
22
+ *
23
+ * bound = bind(greet, object, bind.placeholder, '!');
24
+ * bound('hi');
25
+ * // => 'hi fred!'
26
+ */
27
+ declare function bind(func: (...args: any[]) => any, thisArg?: any, ...partials: any[]): (...args: any[]) => any;
28
+ declare namespace bind {
29
+ var placeholder: symbol;
30
+ }
31
+
32
+ export { bind };
@@ -0,0 +1,32 @@
1
+ /**
2
+ *
3
+ * Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives.
4
+ *
5
+ * The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
6
+ *
7
+ * **Note:** Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions.
8
+ *
9
+ * @param {(...args: any[]) => any} func The function to bind.
10
+ * @param {any} thisArg The `this` binding of `func`.
11
+ * @param {any[]} partials The arguments to be partially applied.
12
+ * @returns {(...args: any[]) => any} Returns the new bound function.
13
+ *
14
+ * @example
15
+ * function greet(greeting, punctuation) {
16
+ * return greeting + ' ' + this.user + punctuation;
17
+ * }
18
+ * const object = { user: 'fred' };
19
+ * let bound = bind(greet, object, 'hi');
20
+ * bound('!');
21
+ * // => 'hi fred!'
22
+ *
23
+ * bound = bind(greet, object, bind.placeholder, '!');
24
+ * bound('hi');
25
+ * // => 'hi fred!'
26
+ */
27
+ declare function bind(func: (...args: any[]) => any, thisArg?: any, ...partials: any[]): (...args: any[]) => any;
28
+ declare namespace bind {
29
+ var placeholder: symbol;
30
+ }
31
+
32
+ export { bind };
@@ -0,0 +1,22 @@
1
+ function bind(func, thisArg, ...partials) {
2
+ const wrapper = function (...args) {
3
+ let index = 0;
4
+ const result = partials.map(bindArg => {
5
+ if (bindArg === bind.placeholder) {
6
+ return args[index++];
7
+ }
8
+ return bindArg;
9
+ });
10
+ for (let i = index; i < args.length; i++) {
11
+ result.push(args[i]);
12
+ }
13
+ if (this instanceof wrapper) {
14
+ return new func(...result);
15
+ }
16
+ return func.apply(thisArg, result);
17
+ };
18
+ return wrapper;
19
+ }
20
+ bind.placeholder = Symbol('bind.placeholder');
21
+
22
+ export { bind };
@@ -5,3 +5,4 @@ export { noop } from './noop.mjs';
5
5
  export { once } from './once.mjs';
6
6
  export { throttle } from './throttle.mjs';
7
7
  export { negate } from './negate.mjs';
8
+ export { bind } from './bind.mjs';
@@ -5,3 +5,4 @@ export { noop } from './noop.js';
5
5
  export { once } from './once.js';
6
6
  export { throttle } from './throttle.js';
7
7
  export { negate } from './negate.js';
8
+ export { bind } from './bind.js';
@@ -87,8 +87,30 @@ function negate(func) {
87
87
  return ((...args) => !func(...args));
88
88
  }
89
89
 
90
+ function bind(func, thisArg, ...partials) {
91
+ const wrapper = function (...args) {
92
+ let index = 0;
93
+ const result = partials.map(bindArg => {
94
+ if (bindArg === bind.placeholder) {
95
+ return args[index++];
96
+ }
97
+ return bindArg;
98
+ });
99
+ for (let i = index; i < args.length; i++) {
100
+ result.push(args[i]);
101
+ }
102
+ if (this instanceof wrapper) {
103
+ return new func(...result);
104
+ }
105
+ return func.apply(thisArg, result);
106
+ };
107
+ return wrapper;
108
+ }
109
+ bind.placeholder = Symbol('bind.placeholder');
110
+
90
111
  exports.after = after;
91
112
  exports.before = before;
113
+ exports.bind = bind;
92
114
  exports.debounce = debounce;
93
115
  exports.negate = negate;
94
116
  exports.noop = noop;
@@ -5,3 +5,4 @@ export { noop } from './noop.mjs';
5
5
  export { once } from './once.mjs';
6
6
  export { throttle } from './throttle.mjs';
7
7
  export { negate } from './negate.mjs';
8
+ export { bind } from './bind.mjs';
package/dist/index.d.mts CHANGED
@@ -45,6 +45,7 @@ export { zipObject } from './array/zipObject.mjs';
45
45
  export { zipWith } from './array/zipWith.mjs';
46
46
  export { without } from './array/without.mjs';
47
47
  export { head } from './array/head.mjs';
48
+ export { isSubset } from './array/isSubset.mjs';
48
49
  export { tail } from './array/tail.mjs';
49
50
  export { toFilled } from './array/toFilled.mjs';
50
51
  export { last } from './array/last.mjs';
@@ -59,6 +60,7 @@ export { noop } from './function/noop.mjs';
59
60
  export { once } from './function/once.mjs';
60
61
  export { throttle } from './function/throttle.mjs';
61
62
  export { negate } from './function/negate.mjs';
63
+ export { bind } from './function/bind.mjs';
62
64
  export { clamp } from './math/clamp.mjs';
63
65
  export { inRange } from './math/inRange.mjs';
64
66
  export { mean } from './math/mean.mjs';
package/dist/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export { zipObject } from './array/zipObject.js';
45
45
  export { zipWith } from './array/zipWith.js';
46
46
  export { without } from './array/without.js';
47
47
  export { head } from './array/head.js';
48
+ export { isSubset } from './array/isSubset.js';
48
49
  export { tail } from './array/tail.js';
49
50
  export { toFilled } from './array/toFilled.js';
50
51
  export { last } from './array/last.js';
@@ -59,6 +60,7 @@ export { noop } from './function/noop.js';
59
60
  export { once } from './function/once.js';
60
61
  export { throttle } from './function/throttle.js';
61
62
  export { negate } from './function/negate.js';
63
+ export { bind } from './function/bind.js';
62
64
  export { clamp } from './math/clamp.js';
63
65
  export { inRange } from './math/inRange.js';
64
66
  export { mean } from './math/mean.js';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const size = require('./_chunk/size-CJyNw8.js');
5
+ const size = require('./_chunk/size-DmGMC-.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const isNil = require('./_chunk/isNil-IuJ4cv.js');
8
8
  const promise_index = require('./_chunk/index-CwRt_M.js');
@@ -36,6 +36,7 @@ exports.initial = size.initial;
36
36
  exports.intersection = size.intersection;
37
37
  exports.intersectionBy = size.intersectionBy;
38
38
  exports.intersectionWith = size.intersectionWith;
39
+ exports.isSubset = size.isSubset;
39
40
  exports.keyBy = size.keyBy;
40
41
  exports.last = size.last;
41
42
  exports.maxBy = size.maxBy;
@@ -75,6 +76,7 @@ exports.delay = promise_index.delay;
75
76
  exports.withTimeout = promise_index.withTimeout;
76
77
  exports.after = function_index.after;
77
78
  exports.before = function_index.before;
79
+ exports.bind = function_index.bind;
78
80
  exports.debounce = function_index.debounce;
79
81
  exports.negate = function_index.negate;
80
82
  exports.noop = function_index.noop;
package/dist/index.mjs CHANGED
@@ -45,6 +45,7 @@ export { zipObject } from './array/zipObject.mjs';
45
45
  export { zipWith } from './array/zipWith.mjs';
46
46
  export { without } from './array/without.mjs';
47
47
  export { head } from './array/head.mjs';
48
+ export { isSubset } from './array/isSubset.mjs';
48
49
  export { tail } from './array/tail.mjs';
49
50
  export { toFilled } from './array/toFilled.mjs';
50
51
  export { last } from './array/last.mjs';
@@ -59,6 +60,7 @@ export { noop } from './function/noop.mjs';
59
60
  export { once } from './function/once.mjs';
60
61
  export { throttle } from './function/throttle.mjs';
61
62
  export { negate } from './function/negate.mjs';
63
+ export { bind } from './function/bind.mjs';
62
64
  export { clamp } from './math/clamp.mjs';
63
65
  export { inRange } from './math/inRange.mjs';
64
66
  export { mean } from './math/mean.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.13.1-dev.367+a4b77c01",
4
+ "version": "1.13.1-dev.369+f198dfd9",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {