es-toolkit 1.23.0-dev.750 → 1.23.0-dev.755
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/array/every.mjs +4 -5
- package/dist/compat/array/filter.mjs +4 -5
- package/dist/compat/array/find.mjs +4 -5
- package/dist/compat/index.d.mts +5 -5
- package/dist/compat/index.d.ts +5 -5
- package/dist/compat/index.js +47 -50
- package/dist/compat/index.mjs +5 -5
- package/dist/compat/predicate/isEqualWith.mjs +1 -1
- package/dist/compat/string/upperCase.mjs +0 -1
- package/dist/compat/util/defaultTo.d.mts +5 -7
- package/dist/compat/util/defaultTo.d.ts +5 -7
- package/dist/compat/util/times.d.mts +8 -12
- package/dist/compat/util/times.d.ts +8 -12
- package/dist/compat/util/times.mjs +2 -2
- package/dist/compat/util/toLength.d.mts +5 -3
- package/dist/compat/util/toLength.d.ts +5 -3
- package/dist/function/index.d.mts +10 -10
- package/dist/function/index.d.ts +10 -10
- package/dist/function/index.js +34 -34
- package/dist/function/index.mjs +10 -10
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +13 -13
- package/dist/index.mjs +10 -10
- package/package.json +2 -2
- package/dist/_chunk/{flowRight-Cf9ldK.js → unary-BZ5Ixo.js} +27 -27
package/dist/function/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const unary = require('../_chunk/unary-BZ5Ixo.js');
|
|
6
6
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
7
7
|
|
|
8
8
|
function before(n, func) {
|
|
@@ -18,27 +18,6 @@ function before(n, func) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] } = {}) {
|
|
22
|
-
let pendingAt = null;
|
|
23
|
-
const debounced = flowRight.debounce(func, throttleMs, { signal, edges });
|
|
24
|
-
const throttled = function (...args) {
|
|
25
|
-
if (pendingAt == null) {
|
|
26
|
-
pendingAt = Date.now();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (Date.now() - pendingAt >= throttleMs) {
|
|
30
|
-
pendingAt = Date.now();
|
|
31
|
-
debounced.cancel();
|
|
32
|
-
debounced(...args);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
debounced(...args);
|
|
36
|
-
};
|
|
37
|
-
throttled.cancel = debounced.cancel;
|
|
38
|
-
throttled.flush = debounced.flush;
|
|
39
|
-
return throttled;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
21
|
function curry(func) {
|
|
43
22
|
if (func.length === 0 || func.length === 1) {
|
|
44
23
|
return func;
|
|
@@ -85,18 +64,39 @@ function spread(func) {
|
|
|
85
64
|
};
|
|
86
65
|
}
|
|
87
66
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
67
|
+
function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] } = {}) {
|
|
68
|
+
let pendingAt = null;
|
|
69
|
+
const debounced = unary.debounce(func, throttleMs, { signal, edges });
|
|
70
|
+
const throttled = function (...args) {
|
|
71
|
+
if (pendingAt == null) {
|
|
72
|
+
pendingAt = Date.now();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (Date.now() - pendingAt >= throttleMs) {
|
|
76
|
+
pendingAt = Date.now();
|
|
77
|
+
debounced.cancel();
|
|
78
|
+
debounced(...args);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
debounced(...args);
|
|
82
|
+
};
|
|
83
|
+
throttled.cancel = debounced.cancel;
|
|
84
|
+
throttled.flush = debounced.flush;
|
|
85
|
+
return throttled;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
exports.after = unary.after;
|
|
89
|
+
exports.ary = unary.ary;
|
|
90
|
+
exports.debounce = unary.debounce;
|
|
91
|
+
exports.flow = unary.flow;
|
|
92
|
+
exports.flowRight = unary.flowRight;
|
|
93
|
+
exports.memoize = unary.memoize;
|
|
94
|
+
exports.negate = unary.negate;
|
|
95
|
+
exports.once = unary.once;
|
|
96
|
+
exports.partial = unary.partial;
|
|
97
|
+
exports.partialRight = unary.partialRight;
|
|
98
|
+
exports.rest = unary.rest;
|
|
99
|
+
exports.unary = unary.unary;
|
|
100
100
|
exports.noop = noop.noop;
|
|
101
101
|
exports.before = before;
|
|
102
102
|
exports.curry = curry;
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { before } from './before.mjs';
|
|
2
1
|
export { after } from './after.mjs';
|
|
2
|
+
export { ary } from './ary.mjs';
|
|
3
|
+
export { before } from './before.mjs';
|
|
4
|
+
export { curry } from './curry.mjs';
|
|
5
|
+
export { curryRight } from './curryRight.mjs';
|
|
3
6
|
export { debounce } from './debounce.mjs';
|
|
7
|
+
export { flow } from './flow.mjs';
|
|
8
|
+
export { flowRight } from './flowRight.mjs';
|
|
9
|
+
export { memoize } from './memoize.mjs';
|
|
10
|
+
export { negate } from './negate.mjs';
|
|
4
11
|
export { noop } from './noop.mjs';
|
|
5
12
|
export { once } from './once.mjs';
|
|
6
|
-
export { throttle } from './throttle.mjs';
|
|
7
|
-
export { negate } from './negate.mjs';
|
|
8
|
-
export { memoize } from './memoize.mjs';
|
|
9
|
-
export { ary } from './ary.mjs';
|
|
10
|
-
export { unary } from './unary.mjs';
|
|
11
13
|
export { partial } from './partial.mjs';
|
|
12
14
|
export { partialRight } from './partialRight.mjs';
|
|
13
15
|
export { rest } from './rest.mjs';
|
|
14
|
-
export { curry } from './curry.mjs';
|
|
15
|
-
export { curryRight } from './curryRight.mjs';
|
|
16
16
|
export { spread } from './spread.mjs';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
17
|
+
export { throttle } from './throttle.mjs';
|
|
18
|
+
export { unary } from './unary.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -56,24 +56,24 @@ export { zipObject } from './array/zipObject.mjs';
|
|
|
56
56
|
export { zipWith } from './array/zipWith.mjs';
|
|
57
57
|
export { AbortError } from './error/AbortError.mjs';
|
|
58
58
|
export { TimeoutError } from './error/TimeoutError.mjs';
|
|
59
|
-
export { before } from './function/before.mjs';
|
|
60
59
|
export { after } from './function/after.mjs';
|
|
60
|
+
export { ary } from './function/ary.mjs';
|
|
61
|
+
export { before } from './function/before.mjs';
|
|
62
|
+
export { curry } from './function/curry.mjs';
|
|
63
|
+
export { curryRight } from './function/curryRight.mjs';
|
|
61
64
|
export { debounce } from './function/debounce.mjs';
|
|
65
|
+
export { flow } from './function/flow.mjs';
|
|
66
|
+
export { flowRight } from './function/flowRight.mjs';
|
|
67
|
+
export { MemoizeCache, memoize } from './function/memoize.mjs';
|
|
68
|
+
export { negate } from './function/negate.mjs';
|
|
62
69
|
export { noop } from './function/noop.mjs';
|
|
63
70
|
export { once } from './function/once.mjs';
|
|
64
|
-
export { throttle } from './function/throttle.mjs';
|
|
65
|
-
export { negate } from './function/negate.mjs';
|
|
66
|
-
export { MemoizeCache, memoize } from './function/memoize.mjs';
|
|
67
|
-
export { ary } from './function/ary.mjs';
|
|
68
|
-
export { unary } from './function/unary.mjs';
|
|
69
71
|
export { partial } from './function/partial.mjs';
|
|
70
72
|
export { partialRight } from './function/partialRight.mjs';
|
|
71
73
|
export { rest } from './function/rest.mjs';
|
|
72
|
-
export { curry } from './function/curry.mjs';
|
|
73
|
-
export { curryRight } from './function/curryRight.mjs';
|
|
74
74
|
export { spread } from './function/spread.mjs';
|
|
75
|
-
export {
|
|
76
|
-
export {
|
|
75
|
+
export { throttle } from './function/throttle.mjs';
|
|
76
|
+
export { unary } from './function/unary.mjs';
|
|
77
77
|
export { clamp } from './math/clamp.mjs';
|
|
78
78
|
export { inRange } from './math/inRange.mjs';
|
|
79
79
|
export { mean } from './math/mean.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -56,24 +56,24 @@ export { zipObject } from './array/zipObject.js';
|
|
|
56
56
|
export { zipWith } from './array/zipWith.js';
|
|
57
57
|
export { AbortError } from './error/AbortError.js';
|
|
58
58
|
export { TimeoutError } from './error/TimeoutError.js';
|
|
59
|
-
export { before } from './function/before.js';
|
|
60
59
|
export { after } from './function/after.js';
|
|
60
|
+
export { ary } from './function/ary.js';
|
|
61
|
+
export { before } from './function/before.js';
|
|
62
|
+
export { curry } from './function/curry.js';
|
|
63
|
+
export { curryRight } from './function/curryRight.js';
|
|
61
64
|
export { debounce } from './function/debounce.js';
|
|
65
|
+
export { flow } from './function/flow.js';
|
|
66
|
+
export { flowRight } from './function/flowRight.js';
|
|
67
|
+
export { MemoizeCache, memoize } from './function/memoize.js';
|
|
68
|
+
export { negate } from './function/negate.js';
|
|
62
69
|
export { noop } from './function/noop.js';
|
|
63
70
|
export { once } from './function/once.js';
|
|
64
|
-
export { throttle } from './function/throttle.js';
|
|
65
|
-
export { negate } from './function/negate.js';
|
|
66
|
-
export { MemoizeCache, memoize } from './function/memoize.js';
|
|
67
|
-
export { ary } from './function/ary.js';
|
|
68
|
-
export { unary } from './function/unary.js';
|
|
69
71
|
export { partial } from './function/partial.js';
|
|
70
72
|
export { partialRight } from './function/partialRight.js';
|
|
71
73
|
export { rest } from './function/rest.js';
|
|
72
|
-
export { curry } from './function/curry.js';
|
|
73
|
-
export { curryRight } from './function/curryRight.js';
|
|
74
74
|
export { spread } from './function/spread.js';
|
|
75
|
-
export {
|
|
76
|
-
export {
|
|
75
|
+
export { throttle } from './function/throttle.js';
|
|
76
|
+
export { unary } from './function/unary.js';
|
|
77
77
|
export { clamp } from './math/clamp.js';
|
|
78
78
|
export { inRange } from './math/inRange.js';
|
|
79
79
|
export { mean } from './math/mean.js';
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const zipWith = require('./_chunk/zipWith-CV0XAX.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
7
|
const promise_index = require('./_chunk/index-BGZDR9.js');
|
|
8
|
+
const unary = require('./_chunk/unary-BZ5Ixo.js');
|
|
8
9
|
const function_index = require('./function/index.js');
|
|
9
|
-
const flowRight = require('./_chunk/flowRight-Cf9ldK.js');
|
|
10
10
|
const noop = require('./_chunk/noop-2IwLUk.js');
|
|
11
11
|
const sumBy = require('./_chunk/sumBy-BkErWJ.js');
|
|
12
12
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
@@ -82,23 +82,23 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
82
82
|
exports.delay = promise_index.delay;
|
|
83
83
|
exports.timeout = promise_index.timeout;
|
|
84
84
|
exports.withTimeout = promise_index.withTimeout;
|
|
85
|
+
exports.after = unary.after;
|
|
86
|
+
exports.ary = unary.ary;
|
|
87
|
+
exports.debounce = unary.debounce;
|
|
88
|
+
exports.flow = unary.flow;
|
|
89
|
+
exports.flowRight = unary.flowRight;
|
|
90
|
+
exports.memoize = unary.memoize;
|
|
91
|
+
exports.negate = unary.negate;
|
|
92
|
+
exports.once = unary.once;
|
|
93
|
+
exports.partial = unary.partial;
|
|
94
|
+
exports.partialRight = unary.partialRight;
|
|
95
|
+
exports.rest = unary.rest;
|
|
96
|
+
exports.unary = unary.unary;
|
|
85
97
|
exports.before = function_index.before;
|
|
86
98
|
exports.curry = function_index.curry;
|
|
87
99
|
exports.curryRight = function_index.curryRight;
|
|
88
100
|
exports.spread = function_index.spread;
|
|
89
101
|
exports.throttle = function_index.throttle;
|
|
90
|
-
exports.after = flowRight.after;
|
|
91
|
-
exports.ary = flowRight.ary;
|
|
92
|
-
exports.debounce = flowRight.debounce;
|
|
93
|
-
exports.flow = flowRight.flow;
|
|
94
|
-
exports.flowRight = flowRight.flowRight;
|
|
95
|
-
exports.memoize = flowRight.memoize;
|
|
96
|
-
exports.negate = flowRight.negate;
|
|
97
|
-
exports.once = flowRight.once;
|
|
98
|
-
exports.partial = flowRight.partial;
|
|
99
|
-
exports.partialRight = flowRight.partialRight;
|
|
100
|
-
exports.rest = flowRight.rest;
|
|
101
|
-
exports.unary = flowRight.unary;
|
|
102
102
|
exports.noop = noop.noop;
|
|
103
103
|
exports.clamp = sumBy.clamp;
|
|
104
104
|
exports.inRange = sumBy.inRange;
|
package/dist/index.mjs
CHANGED
|
@@ -56,24 +56,24 @@ export { zipObject } from './array/zipObject.mjs';
|
|
|
56
56
|
export { zipWith } from './array/zipWith.mjs';
|
|
57
57
|
export { AbortError } from './error/AbortError.mjs';
|
|
58
58
|
export { TimeoutError } from './error/TimeoutError.mjs';
|
|
59
|
-
export { before } from './function/before.mjs';
|
|
60
59
|
export { after } from './function/after.mjs';
|
|
60
|
+
export { ary } from './function/ary.mjs';
|
|
61
|
+
export { before } from './function/before.mjs';
|
|
62
|
+
export { curry } from './function/curry.mjs';
|
|
63
|
+
export { curryRight } from './function/curryRight.mjs';
|
|
61
64
|
export { debounce } from './function/debounce.mjs';
|
|
65
|
+
export { flow } from './function/flow.mjs';
|
|
66
|
+
export { flowRight } from './function/flowRight.mjs';
|
|
67
|
+
export { memoize } from './function/memoize.mjs';
|
|
68
|
+
export { negate } from './function/negate.mjs';
|
|
62
69
|
export { noop } from './function/noop.mjs';
|
|
63
70
|
export { once } from './function/once.mjs';
|
|
64
|
-
export { throttle } from './function/throttle.mjs';
|
|
65
|
-
export { negate } from './function/negate.mjs';
|
|
66
|
-
export { memoize } from './function/memoize.mjs';
|
|
67
|
-
export { ary } from './function/ary.mjs';
|
|
68
|
-
export { unary } from './function/unary.mjs';
|
|
69
71
|
export { partial } from './function/partial.mjs';
|
|
70
72
|
export { partialRight } from './function/partialRight.mjs';
|
|
71
73
|
export { rest } from './function/rest.mjs';
|
|
72
|
-
export { curry } from './function/curry.mjs';
|
|
73
|
-
export { curryRight } from './function/curryRight.mjs';
|
|
74
74
|
export { spread } from './function/spread.mjs';
|
|
75
|
-
export {
|
|
76
|
-
export {
|
|
75
|
+
export { throttle } from './function/throttle.mjs';
|
|
76
|
+
export { unary } from './function/unary.mjs';
|
|
77
77
|
export { clamp } from './math/clamp.mjs';
|
|
78
78
|
export { inRange } from './math/inRange.mjs';
|
|
79
79
|
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.23.0-dev.
|
|
4
|
+
"version": "1.23.0-dev.755+c5bbf032",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"globals": "^15.9.0",
|
|
238
238
|
"jscodeshift": "^17.0.0",
|
|
239
239
|
"prettier": "^3.2.5",
|
|
240
|
-
"prettier-plugin-sort-re-exports": "^0.0
|
|
240
|
+
"prettier-plugin-sort-re-exports": "^0.1.0",
|
|
241
241
|
"rollup": "^4.19.0",
|
|
242
242
|
"rollup-plugin-dts": "^6.1.1",
|
|
243
243
|
"tar": "^6",
|
|
@@ -13,6 +13,12 @@ function after(n, func) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function ary(func, n) {
|
|
17
|
+
return function (...args) {
|
|
18
|
+
return func.apply(this, args.slice(0, n));
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
17
23
|
let pendingThis = undefined;
|
|
18
24
|
let pendingArgs = null;
|
|
@@ -75,20 +81,18 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
75
81
|
return debounced;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
function
|
|
79
|
-
let called = false;
|
|
80
|
-
let cache;
|
|
84
|
+
function flow(...funcs) {
|
|
81
85
|
return function (...args) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
let result = funcs.length ? funcs[0].apply(this, args) : args[0];
|
|
87
|
+
for (let i = 1; i < funcs.length; i++) {
|
|
88
|
+
result = funcs[i].call(this, result);
|
|
85
89
|
}
|
|
86
|
-
return
|
|
90
|
+
return result;
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
function
|
|
91
|
-
return (
|
|
94
|
+
function flowRight(...funcs) {
|
|
95
|
+
return flow(...funcs.reverse());
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
function memoize(fn, options = {}) {
|
|
@@ -106,14 +110,20 @@ function memoize(fn, options = {}) {
|
|
|
106
110
|
return memoizedFn;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
function
|
|
110
|
-
return
|
|
111
|
-
return func.apply(this, args.slice(0, n));
|
|
112
|
-
};
|
|
113
|
+
function negate(func) {
|
|
114
|
+
return ((...args) => !func(...args));
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
+
function once(func) {
|
|
118
|
+
let called = false;
|
|
119
|
+
let cache;
|
|
120
|
+
return function (...args) {
|
|
121
|
+
if (!called) {
|
|
122
|
+
called = true;
|
|
123
|
+
cache = func(...args);
|
|
124
|
+
}
|
|
125
|
+
return cache;
|
|
126
|
+
};
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
function partial(func, ...partialArgs) {
|
|
@@ -173,18 +183,8 @@ function rest(func, startIndex = func.length - 1) {
|
|
|
173
183
|
};
|
|
174
184
|
}
|
|
175
185
|
|
|
176
|
-
function
|
|
177
|
-
return
|
|
178
|
-
let result = funcs.length ? funcs[0].apply(this, args) : args[0];
|
|
179
|
-
for (let i = 1; i < funcs.length; i++) {
|
|
180
|
-
result = funcs[i].call(this, result);
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function flowRight(...funcs) {
|
|
187
|
-
return flow(...funcs.reverse());
|
|
186
|
+
function unary(func) {
|
|
187
|
+
return ary(func, 1);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
exports.after = after;
|