@applitools/utils
Advanced tools
+7
-0
| # Changelog | ||
| ## [1.8.2](https://github.com/Applitools-Dev/sdk/compare/js/utils@1.8.1...js/utils@1.8.2) (2025-05-11) | ||
| ### Bug Fixes | ||
| * remove redundant file readings and added rendering concurrency limit ([#2956](https://github.com/Applitools-Dev/sdk/issues/2956)) ([b970180](https://github.com/Applitools-Dev/sdk/commit/b97018010fdf12cb0d202192b22f643c16c569d5)) | ||
| ## [1.8.1](https://github.com/Applitools-Dev/sdk/compare/js/utils@1.8.0...js/utils@1.8.1) (2025-05-07) | ||
@@ -4,0 +11,0 @@ |
+15
-8
@@ -133,4 +133,4 @@ "use strict"; | ||
| exports.cachify = cachify; | ||
| function batchify(func, { timeout }) { | ||
| let pendingInputs = new Map(); | ||
| function batchify(func, { timeout, maxPending }) { | ||
| const pendingInputs = new Map(); | ||
| let throttleTimer = false; | ||
@@ -141,11 +141,18 @@ return function (input) { | ||
| if (!throttleTimer) { | ||
| throttleTimer = true; | ||
| setTimeout(() => { | ||
| func(Array.from(pendingInputs.entries())); | ||
| pendingInputs = new Map(); | ||
| throttleTimer = false; | ||
| }, timeout); | ||
| throttleTimer = setTimeout(invoke, timeout); | ||
| } | ||
| if (maxPending && pendingInputs.size >= maxPending) { | ||
| invoke(); | ||
| } | ||
| }); | ||
| }; | ||
| function invoke() { | ||
| if (pendingInputs.size) { | ||
| func(Array.from(pendingInputs.entries())); | ||
| pendingInputs.clear(); | ||
| if (throttleTimer) | ||
| clearTimeout(throttleTimer); | ||
| throttleTimer = false; | ||
| } | ||
| } | ||
| } | ||
@@ -152,0 +159,0 @@ exports.batchify = batchify; |
+1
-1
| { | ||
| "name": "@applitools/utils", | ||
| "version": "1.8.1", | ||
| "version": "1.8.2", | ||
| "keywords": [ | ||
@@ -5,0 +5,0 @@ "applitools", |
@@ -34,4 +34,5 @@ export declare function getEnvValue<T extends 'boolean' | 'number' | 'string' = 'string'>(name: string, type?: T): T extends 'boolean' ? boolean : T extends 'number' ? number : T extends 'string' ? string : string | undefined; | ||
| reject(reason?: any): void; | ||
| }][]) => Promise<void>, TInput = Parameters<TFunc>[0][number][0], TResult = Parameters<Parameters<TFunc>[0][number][1]['resolve']>[0]>(func: TFunc, { timeout }: { | ||
| }][]) => Promise<void>, TInput = Parameters<TFunc>[0][number][0], TResult = Parameters<Parameters<TFunc>[0][number][1]['resolve']>[0]>(func: TFunc, { timeout, maxPending }: { | ||
| timeout: number; | ||
| maxPending?: number; | ||
| }): (input: Parameters<TFunc>[0][number][0]) => Promise<TResult>; | ||
@@ -38,0 +39,0 @@ export declare function wrap<TFunc extends (...args: any[]) => any>(func: TFunc, wrapper: (func: TFunc, ...args: Parameters<TFunc>) => ReturnType<TFunc>): TFunc; |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
91976
0.65%1660
0.48%