Socket
Socket
Sign inDemoInstall

es-toolkit

Package Overview
Dependencies
Maintainers
2
Versions
722
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-toolkit - npm Package Compare versions

Comparing version 1.3.1-dev.76 to 1.3.1-dev.78

dist/chunk-AL3GJBEI.mjs

3

dist/function/debounce.js

@@ -48,5 +48,4 @@ "use strict";

}
signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
};
signal == null ? void 0 : signal.addEventListener("abort", onAbort);
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
return debounced;

@@ -53,0 +52,0 @@ }

@@ -53,5 +53,4 @@ "use strict";

}
signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
};
signal == null ? void 0 : signal.addEventListener("abort", onAbort);
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
return debounced;

@@ -58,0 +57,0 @@ }

@@ -31,2 +31,3 @@ export { chunk } from './array/chunk.js';

export { zipWith } from './array/zipWith.js';
export { AbortError } from './error/AbortError.js';
export { debounce } from './function/debounce.js';

@@ -33,0 +34,0 @@ export { noop } from './function/noop.js';

@@ -37,2 +37,3 @@ "use strict";

__export(src_exports, {
AbortError: () => AbortError,
chunk: () => chunk,

@@ -342,2 +343,10 @@ clamp: () => clamp,

// src/error/AbortError.ts
var AbortError = class extends Error {
constructor(message = "The operation was aborted") {
super(message);
this.name = "AbortError";
}
};
// src/function/debounce.ts

@@ -366,5 +375,4 @@ function debounce(func, debounceMs, { signal } = {}) {

}
signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
};
signal == null ? void 0 : signal.addEventListener("abort", onAbort);
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
return debounced;

@@ -491,5 +499,16 @@ }

// src/promise/delay.ts
function delay(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
function delay(ms, { signal } = {}) {
return new Promise((resolve, reject) => {
const abortError = () => {
reject(new AbortError());
};
const abortHandler = () => {
clearTimeout(timeoutId);
abortError();
};
if (signal == null ? void 0 : signal.aborted) {
return abortError();
}
const timeoutId = setTimeout(resolve, ms);
signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
});

@@ -499,2 +518,3 @@ }

0 && (module.exports = {
AbortError,
chunk,

@@ -501,0 +521,0 @@ clamp,

@@ -0,1 +1,4 @@

interface DelayOptions {
signal?: AbortSignal;
}
/**

@@ -8,2 +11,4 @@ * Delays the execution of code for a specified number of milliseconds.

* @param {number} ms - The number of milliseconds to delay.
* @param {DelayOptions} options - The options object.
* @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.
* @returns {Promise<void>} A Promise that resolves after the specified delay.

@@ -19,5 +24,17 @@ *

* foo();
*
* // With AbortSignal
* const controller = new AbortController();
* const { signal } = controller;
*
* setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms
* try {
* await delay(100, { signal });
* } catch (error) {
* console.error(error); // Will log 'AbortError'
* }
* }
*/
declare function delay(ms: number): Promise<void>;
declare function delay(ms: number, { signal }?: DelayOptions): Promise<void>;
export { delay };

@@ -26,5 +26,26 @@ "use strict";

module.exports = __toCommonJS(delay_exports);
function delay(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
// src/error/AbortError.ts
var AbortError = class extends Error {
constructor(message = "The operation was aborted") {
super(message);
this.name = "AbortError";
}
};
// src/promise/delay.ts
function delay(ms, { signal } = {}) {
return new Promise((resolve, reject) => {
const abortError = () => {
reject(new AbortError());
};
const abortHandler = () => {
clearTimeout(timeoutId);
abortError();
};
if (signal == null ? void 0 : signal.aborted) {
return abortError();
}
const timeoutId = setTimeout(resolve, ms);
signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
});

@@ -31,0 +52,0 @@ }

@@ -27,6 +27,25 @@ "use strict";

// src/error/AbortError.ts
var AbortError = class extends Error {
constructor(message = "The operation was aborted") {
super(message);
this.name = "AbortError";
}
};
// src/promise/delay.ts
function delay(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
function delay(ms, { signal } = {}) {
return new Promise((resolve, reject) => {
const abortError = () => {
reject(new AbortError());
};
const abortHandler = () => {
clearTimeout(timeoutId);
abortError();
};
if (signal == null ? void 0 : signal.aborted) {
return abortError();
}
const timeoutId = setTimeout(resolve, ms);
signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
});

@@ -33,0 +52,0 @@ }

{
"name": "es-toolkit",
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
"version": "1.3.1-dev.76+50c35858",
"version": "1.3.1-dev.78+8d80869f",
"workspaces": [

@@ -6,0 +6,0 @@ "docs"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc