Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@azure/core-util

Package Overview
Dependencies
Maintainers
2
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-util - npm Package Compare versions

Comparing version 1.9.3-alpha.20240808.1 to 1.9.3-alpha.20240809.2

12

dist/browser/delay.d.ts

@@ -14,2 +14,14 @@ import type { AbortOptions } from "./aborterUtils.js";

export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export declare function calculateRetryDelay(retryAttempt: number, config: {
retryDelayInMs: number;
maxRetryDelayInMs: number;
}): {
retryAfterInMs: number;
};
//# sourceMappingURL=delay.d.ts.map
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createAbortablePromise } from "./createAbortablePromise.js";
import { getRandomIntegerInclusive } from "./random.js";
const StandardAbortMessage = "The delay was aborted.";

@@ -22,2 +23,18 @@ /**

}
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export function calculateRetryDelay(retryAttempt, config) {
// Exponentially increase the delay each time
const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);
// Don't let the delay exceed the maximum
const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);
// Allow the final value to have some "jitter" (within 50% of the delay size) so
// that retries across multiple clients don't occur simultaneously.
const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);
return { retryAfterInMs };
}
//# sourceMappingURL=delay.js.map

2

dist/browser/index.d.ts

@@ -1,2 +0,2 @@

export { delay, type DelayOptions } from "./delay.js";
export { delay, type DelayOptions, calculateRetryDelay } from "./delay.js";
export { type AbortOptions, cancelablePromiseRace, type AbortablePromiseBuilder, } from "./aborterUtils.js";

@@ -3,0 +3,0 @@ export { createAbortablePromise, type CreateAbortablePromiseOptions, } from "./createAbortablePromise.js";

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { delay } from "./delay.js";
export { delay, calculateRetryDelay } from "./delay.js";
export { cancelablePromiseRace, } from "./aborterUtils.js";

@@ -5,0 +5,0 @@ export { createAbortablePromise, } from "./createAbortablePromise.js";

@@ -14,2 +14,14 @@ import type { AbortOptions } from "./aborterUtils.js";

export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export declare function calculateRetryDelay(retryAttempt: number, config: {
retryDelayInMs: number;
maxRetryDelayInMs: number;
}): {
retryAfterInMs: number;
};
//# sourceMappingURL=delay.d.ts.map

@@ -6,3 +6,5 @@ "use strict";

exports.delay = delay;
exports.calculateRetryDelay = calculateRetryDelay;
const createAbortablePromise_js_1 = require("./createAbortablePromise.js");
const random_js_1 = require("./random.js");
const StandardAbortMessage = "The delay was aborted.";

@@ -26,2 +28,18 @@ /**

}
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
function calculateRetryDelay(retryAttempt, config) {
// Exponentially increase the delay each time
const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);
// Don't let the delay exceed the maximum
const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);
// Allow the final value to have some "jitter" (within 50% of the delay size) so
// that retries across multiple clients don't occur simultaneously.
const retryAfterInMs = clampedDelay / 2 + (0, random_js_1.getRandomIntegerInclusive)(0, clampedDelay / 2);
return { retryAfterInMs };
}
//# sourceMappingURL=delay.js.map

@@ -1,2 +0,2 @@

export { delay, type DelayOptions } from "./delay.js";
export { delay, type DelayOptions, calculateRetryDelay } from "./delay.js";
export { type AbortOptions, cancelablePromiseRace, type AbortablePromiseBuilder, } from "./aborterUtils.js";

@@ -3,0 +3,0 @@ export { createAbortablePromise, type CreateAbortablePromiseOptions, } from "./createAbortablePromise.js";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToUint8Array = exports.uint8ArrayToString = exports.isWebWorker = exports.isReactNative = exports.isDeno = exports.isNodeRuntime = exports.isNodeLike = exports.isNode = exports.isBun = exports.isBrowser = exports.randomUUID = exports.objectHasProperty = exports.isObjectWithProperties = exports.isDefined = exports.computeSha256Hmac = exports.computeSha256Hash = exports.getErrorMessage = exports.isError = exports.isObject = exports.getRandomIntegerInclusive = exports.createAbortablePromise = exports.cancelablePromiseRace = exports.delay = void 0;
exports.stringToUint8Array = exports.uint8ArrayToString = exports.isWebWorker = exports.isReactNative = exports.isDeno = exports.isNodeRuntime = exports.isNodeLike = exports.isNode = exports.isBun = exports.isBrowser = exports.randomUUID = exports.objectHasProperty = exports.isObjectWithProperties = exports.isDefined = exports.computeSha256Hmac = exports.computeSha256Hash = exports.getErrorMessage = exports.isError = exports.isObject = exports.getRandomIntegerInclusive = exports.createAbortablePromise = exports.cancelablePromiseRace = exports.calculateRetryDelay = exports.delay = void 0;
var delay_js_1 = require("./delay.js");
Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return delay_js_1.delay; } });
Object.defineProperty(exports, "calculateRetryDelay", { enumerable: true, get: function () { return delay_js_1.calculateRetryDelay; } });
var aborterUtils_js_1 = require("./aborterUtils.js");

@@ -10,0 +11,0 @@ Object.defineProperty(exports, "cancelablePromiseRace", { enumerable: true, get: function () { return aborterUtils_js_1.cancelablePromiseRace; } });

@@ -25,2 +25,15 @@ import type { AbortSignalLike } from '@azure/abort-controller';

/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export declare function calculateRetryDelay(retryAttempt: number, config: {
retryDelayInMs: number;
maxRetryDelayInMs: number;
}): {
retryAfterInMs: number;
};
/**
* promise.race() wrapper that aborts rest of promises as soon as the first promise settles.

@@ -27,0 +40,0 @@ */

@@ -14,2 +14,14 @@ import type { AbortOptions } from "./aborterUtils.js";

export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export declare function calculateRetryDelay(retryAttempt: number, config: {
retryDelayInMs: number;
maxRetryDelayInMs: number;
}): {
retryAfterInMs: number;
};
//# sourceMappingURL=delay.d.ts.map
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createAbortablePromise } from "./createAbortablePromise.js";
import { getRandomIntegerInclusive } from "./random.js";
const StandardAbortMessage = "The delay was aborted.";

@@ -22,2 +23,18 @@ /**

}
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export function calculateRetryDelay(retryAttempt, config) {
// Exponentially increase the delay each time
const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);
// Don't let the delay exceed the maximum
const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);
// Allow the final value to have some "jitter" (within 50% of the delay size) so
// that retries across multiple clients don't occur simultaneously.
const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);
return { retryAfterInMs };
}
//# sourceMappingURL=delay.js.map

@@ -1,2 +0,2 @@

export { delay, type DelayOptions } from "./delay.js";
export { delay, type DelayOptions, calculateRetryDelay } from "./delay.js";
export { type AbortOptions, cancelablePromiseRace, type AbortablePromiseBuilder, } from "./aborterUtils.js";

@@ -3,0 +3,0 @@ export { createAbortablePromise, type CreateAbortablePromiseOptions, } from "./createAbortablePromise.js";

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { delay } from "./delay.js";
export { delay, calculateRetryDelay } from "./delay.js";
export { cancelablePromiseRace, } from "./aborterUtils.js";

@@ -5,0 +5,0 @@ export { createAbortablePromise, } from "./createAbortablePromise.js";

@@ -14,2 +14,14 @@ import type { AbortOptions } from "./aborterUtils.js";

export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export declare function calculateRetryDelay(retryAttempt: number, config: {
retryDelayInMs: number;
maxRetryDelayInMs: number;
}): {
retryAfterInMs: number;
};
//# sourceMappingURL=delay.d.ts.map
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createAbortablePromise } from "./createAbortablePromise.js";
import { getRandomIntegerInclusive } from "./random.js";
const StandardAbortMessage = "The delay was aborted.";

@@ -22,2 +23,18 @@ /**

}
/**
* Calculates the delay interval for retry attempts using exponential delay with jitter.
* @param retryAttempt - The current retry attempt number.
* @param config - The exponential retry configuration.
* @returns An object containing the calculated retry delay.
*/
export function calculateRetryDelay(retryAttempt, config) {
// Exponentially increase the delay each time
const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);
// Don't let the delay exceed the maximum
const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);
// Allow the final value to have some "jitter" (within 50% of the delay size) so
// that retries across multiple clients don't occur simultaneously.
const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);
return { retryAfterInMs };
}
//# sourceMappingURL=delay.js.map

@@ -1,2 +0,2 @@

export { delay, type DelayOptions } from "./delay.js";
export { delay, type DelayOptions, calculateRetryDelay } from "./delay.js";
export { type AbortOptions, cancelablePromiseRace, type AbortablePromiseBuilder, } from "./aborterUtils.js";

@@ -3,0 +3,0 @@ export { createAbortablePromise, type CreateAbortablePromiseOptions, } from "./createAbortablePromise.js";

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { delay } from "./delay.js";
export { delay, calculateRetryDelay } from "./delay.js";
export { cancelablePromiseRace, } from "./aborterUtils.js";

@@ -5,0 +5,0 @@ export { createAbortablePromise, } from "./createAbortablePromise.js";

{
"name": "@azure/core-util",
"version": "1.9.3-alpha.20240808.1",
"version": "1.9.3-alpha.20240809.2",
"description": "Core library for shared utility methods",

@@ -5,0 +5,0 @@ "sdk-type": "client",

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

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