@applitools/utils
Advanced tools
+7
-0
| # Changelog | ||
| ## [1.8.1](https://github.com/Applitools-Dev/sdk/compare/js/utils@1.8.0...js/utils@1.8.1) (2025-05-07) | ||
| ### Bug Fixes | ||
| * offline test dist readings | AD-9894 ([#2945](https://github.com/Applitools-Dev/sdk/issues/2945)) ([92293f4](https://github.com/Applitools-Dev/sdk/commit/92293f40ddbbb015fba224a70158bbd0cdbcf799)) | ||
| ## [1.8.0](https://github.com/Applitools-Dev/sdk/compare/js/utils@1.7.8...js/utils@1.8.0) (2025-03-30) | ||
@@ -4,0 +11,0 @@ |
+26
-8
@@ -26,3 +26,3 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.dedupAndMap = exports.deepEqual = exports.pluralize = exports.extend = exports.wrap = exports.batchify = exports.cachify = exports.absolutizeUrl = exports.removeUndefinedProps = exports.toUriEncoding = exports.toUnAnchoredUri = exports.toString = exports.toJSON = exports.sleep = exports.jwtDecode = exports.shortid = exports.guid = exports.getEnvValue = void 0; | ||
| exports.zip = exports.dedupAndMap = exports.deepEqual = exports.pluralize = exports.extend = exports.wrap = exports.batchify = exports.cachify = exports.absolutizeUrl = exports.removeUndefinedProps = exports.toUriEncoding = exports.toUnAnchoredUri = exports.toString = exports.toJSON = exports.sleep = exports.jwtDecode = exports.shortid = exports.guid = exports.getEnvValue = void 0; | ||
| const buffer_1 = require("buffer"); | ||
@@ -134,3 +134,3 @@ const types = __importStar(require("./types")); | ||
| exports.cachify = cachify; | ||
| function batchify(func, { timeout }) { | ||
| function batchify(func, { timeout, maxPending }) { | ||
| let pendingInputs = new Map(); | ||
@@ -142,11 +142,18 @@ let throttleTimer = false; | ||
| 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 = new Map(); | ||
| if (throttleTimer) | ||
| clearTimeout(throttleTimer); | ||
| throttleTimer = false; | ||
| } | ||
| } | ||
| } | ||
@@ -244,1 +251,12 @@ exports.batchify = batchify; | ||
| exports.dedupAndMap = dedupAndMap; | ||
| /** | ||
| * Zips two arrays together, yielding pairs of elements from each array. | ||
| * If the arrays are of different lengths, the shorter length is used (it's the user res) | ||
| */ | ||
| function* zip(a, b) { | ||
| const len = Math.min(a.length, b.length); | ||
| for (let i = 0; i < len; i++) { | ||
| yield [a[i], b[i]]; | ||
| } | ||
| } | ||
| exports.zip = zip; |
+1
-1
| { | ||
| "name": "@applitools/utils", | ||
| "version": "1.8.0", | ||
| "version": "1.8.1-debug-20250507.0", | ||
| "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>; | ||
@@ -52,1 +53,6 @@ export declare function wrap<TFunc extends (...args: any[]) => any>(func: TFunc, wrapper: (func: TFunc, ...args: Parameters<TFunc>) => ReturnType<TFunc>): TFunc; | ||
| export declare function dedupAndMap<T extends object, R>(items: T[], transform: (arr: T[]) => Promise<R[]>, isEqual: (a: T, b: T) => boolean): Promise<R[]>; | ||
| /** | ||
| * Zips two arrays together, yielding pairs of elements from each array. | ||
| * If the arrays are of different lengths, the shorter length is used (it's the user res) | ||
| */ | ||
| export declare function zip<A, B>(a: A[], b: B[]): Generator<[A, B]>; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
91643
1.28%1660
1.47%1
Infinity%3
50%