es-toolkit 1.20.0-dev.652 → 1.20.0-dev.653
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/defer.d.mts +16 -0
- package/dist/compat/function/defer.d.ts +16 -0
- package/dist/compat/function/defer.mjs +8 -0
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +8 -0
- package/dist/compat/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
|
|
3
|
+
*
|
|
4
|
+
* @param {F} func The function to defer.
|
|
5
|
+
* @param {Parameters<F>} args The arguments to invoke `func` with.
|
|
6
|
+
* @returns {number} Returns the timer id.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* defer((text) => {
|
|
10
|
+
* console.log(text);
|
|
11
|
+
* }, 'deferred');
|
|
12
|
+
* // => Logs 'deferred' after the current call stack has cleared.
|
|
13
|
+
*/
|
|
14
|
+
declare function defer<F extends (...args: any[]) => any>(func: F, ...args: Parameters<F>): number;
|
|
15
|
+
|
|
16
|
+
export { defer };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
|
|
3
|
+
*
|
|
4
|
+
* @param {F} func The function to defer.
|
|
5
|
+
* @param {Parameters<F>} args The arguments to invoke `func` with.
|
|
6
|
+
* @returns {number} Returns the timer id.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* defer((text) => {
|
|
10
|
+
* console.log(text);
|
|
11
|
+
* }, 'deferred');
|
|
12
|
+
* // => Logs 'deferred' after the current call stack has cleared.
|
|
13
|
+
*/
|
|
14
|
+
declare function defer<F extends (...args: any[]) => any>(func: F, ...args: Parameters<F>): number;
|
|
15
|
+
|
|
16
|
+
export { defer };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -112,6 +112,7 @@ export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
|
112
112
|
export { ary } from './function/ary.mjs';
|
|
113
113
|
export { bind } from './function/bind.mjs';
|
|
114
114
|
export { bindKey } from './function/bindKey.mjs';
|
|
115
|
+
export { defer } from './function/defer.mjs';
|
|
115
116
|
export { rest } from './function/rest.mjs';
|
|
116
117
|
export { spread } from './function/spread.mjs';
|
|
117
118
|
export { attempt } from './function/attempt.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export { zipObjectDeep } from './array/zipObjectDeep.js';
|
|
|
112
112
|
export { ary } from './function/ary.js';
|
|
113
113
|
export { bind } from './function/bind.js';
|
|
114
114
|
export { bindKey } from './function/bindKey.js';
|
|
115
|
+
export { defer } from './function/defer.js';
|
|
115
116
|
export { rest } from './function/rest.js';
|
|
116
117
|
export { spread } from './function/spread.js';
|
|
117
118
|
export { attempt } from './function/attempt.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -785,6 +785,13 @@ function bindKey(object, key, ...partialArgs) {
|
|
|
785
785
|
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
786
786
|
bindKey.placeholder = bindKeyPlaceholder;
|
|
787
787
|
|
|
788
|
+
function defer(func, ...args) {
|
|
789
|
+
if (typeof func !== 'function') {
|
|
790
|
+
throw new TypeError('Expected a function');
|
|
791
|
+
}
|
|
792
|
+
return setTimeout(func, 1, ...args);
|
|
793
|
+
}
|
|
794
|
+
|
|
788
795
|
function rest(func, start = func.length - 1) {
|
|
789
796
|
start = Number.parseInt(start, 10);
|
|
790
797
|
if (Number.isNaN(start) || start < 0) {
|
|
@@ -1727,6 +1734,7 @@ exports.conforms = conforms;
|
|
|
1727
1734
|
exports.conformsTo = conformsTo;
|
|
1728
1735
|
exports.curry = curry;
|
|
1729
1736
|
exports.debounce = debounce;
|
|
1737
|
+
exports.defer = defer;
|
|
1730
1738
|
exports.difference = difference;
|
|
1731
1739
|
exports.drop = drop;
|
|
1732
1740
|
exports.endsWith = endsWith;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -113,6 +113,7 @@ export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
|
113
113
|
export { ary } from './function/ary.mjs';
|
|
114
114
|
export { bind } from './function/bind.mjs';
|
|
115
115
|
export { bindKey } from './function/bindKey.mjs';
|
|
116
|
+
export { defer } from './function/defer.mjs';
|
|
116
117
|
export { rest } from './function/rest.mjs';
|
|
117
118
|
export { spread } from './function/spread.mjs';
|
|
118
119
|
export { attempt } from './function/attempt.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.20.0-dev.
|
|
4
|
+
"version": "1.20.0-dev.653+36b14bef",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|