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

@azure/core-util

Package Overview
Dependencies
Maintainers
1
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.1.2-alpha.20221107.4 to 1.1.2-alpha.20230209.1

40

dist-esm/src/delay.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { AbortError } from "@azure/abort-controller";
import { isDefined } from "./typeGuards";
const StandardAbortMessage = "The operation was aborted.";
const StandardAbortMessage = "The delay was aborted.";
/**

@@ -14,32 +13,27 @@ * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.

return new Promise((resolve, reject) => {
let timer = undefined;
let onAborted = undefined;
const rejectOnAbort = () => {
var _a, _b;
function rejectOnAbort() {
var _a;
return reject(new AbortError((_a = options === null || options === void 0 ? void 0 : options.abortErrorMsg) !== null && _a !== void 0 ? _a : StandardAbortMessage));
};
const removeListeners = () => {
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && onAborted) {
options.abortSignal.removeEventListener("abort", onAborted);
}
};
onAborted = () => {
if (isDefined(timer)) {
clearTimeout(timer);
}
reject(new AbortError((_a = options === null || options === void 0 ? void 0 : options.abortErrorMsg) !== null && _a !== void 0 ? _a : StandardAbortMessage));
}
function removeListeners() {
var _a;
(_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", onAbort);
}
function onAbort() {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
clearTimeout(token);
removeListeners();
rejectOnAbort();
}
if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
return rejectOnAbort();
};
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && options.abortSignal.aborted) {
return rejectOnAbort();
}
timer = setTimeout(() => {
const token = setTimeout(() => {
removeListeners();
resolve();
}, timeInMs);
if (options === null || options === void 0 ? void 0 : options.abortSignal) {
options.abortSignal.addEventListener("abort", onAborted);
}
(_b = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _b === void 0 ? void 0 : _b.addEventListener("abort", onAbort);
});
}
//# sourceMappingURL=delay.js.map

@@ -17,38 +17,4 @@ 'use strict';

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const StandardAbortMessage = "The delay was aborted.";
/**
* Helper TypeGuard that checks if something is defined or not.
* @param thing - Anything
*/
function isDefined(thing) {
return typeof thing !== "undefined" && thing !== null;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified properties.
* @param thing - Anything.
* @param properties - The name of the properties that should appear in the object.
*/
function isObjectWithProperties(thing, properties) {
if (!isDefined(thing) || typeof thing !== "object") {
return false;
}
for (const property of properties) {
if (!objectHasProperty(thing, property)) {
return false;
}
}
return true;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified property.
* @param thing - Any object.
* @param property - The name of the property that should appear in the object.
*/
function objectHasProperty(thing, property) {
return (isDefined(thing) && typeof thing === "object" && property in thing);
}
// Copyright (c) Microsoft Corporation.
const StandardAbortMessage = "The operation was aborted.";
/**
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.

@@ -61,30 +27,25 @@ * @param timeInMs - The number of milliseconds to be delayed.

return new Promise((resolve, reject) => {
let timer = undefined;
let onAborted = undefined;
const rejectOnAbort = () => {
var _a, _b;
function rejectOnAbort() {
var _a;
return reject(new abortController.AbortError((_a = options === null || options === void 0 ? void 0 : options.abortErrorMsg) !== null && _a !== void 0 ? _a : StandardAbortMessage));
};
const removeListeners = () => {
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && onAborted) {
options.abortSignal.removeEventListener("abort", onAborted);
}
};
onAborted = () => {
if (isDefined(timer)) {
clearTimeout(timer);
}
reject(new abortController.AbortError((_a = options === null || options === void 0 ? void 0 : options.abortErrorMsg) !== null && _a !== void 0 ? _a : StandardAbortMessage));
}
function removeListeners() {
var _a;
(_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", onAbort);
}
function onAbort() {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
clearTimeout(token);
removeListeners();
rejectOnAbort();
}
if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
return rejectOnAbort();
};
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && options.abortSignal.aborted) {
return rejectOnAbort();
}
timer = setTimeout(() => {
const token = setTimeout(() => {
removeListeners();
resolve();
}, timeInMs);
if (options === null || options === void 0 ? void 0 : options.abortSignal) {
options.abortSignal.addEventListener("abort", onAborted);
}
(_b = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _b === void 0 ? void 0 : _b.addEventListener("abort", onAbort);
});

@@ -188,2 +149,36 @@ }

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Helper TypeGuard that checks if something is defined or not.
* @param thing - Anything
*/
function isDefined(thing) {
return typeof thing !== "undefined" && thing !== null;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified properties.
* @param thing - Anything.
* @param properties - The name of the properties that should appear in the object.
*/
function isObjectWithProperties(thing, properties) {
if (!isDefined(thing) || typeof thing !== "object") {
return false;
}
for (const property of properties) {
if (!objectHasProperty(thing, property)) {
return false;
}
}
return true;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified property.
* @param thing - Any object.
* @param property - The name of the property that should appear in the object.
*/
function objectHasProperty(thing, property) {
return (isDefined(thing) && typeof thing === "object" && property in thing);
}
exports.computeSha256Hash = computeSha256Hash;

@@ -190,0 +185,0 @@ exports.computeSha256Hmac = computeSha256Hmac;

{
"name": "@azure/core-util",
"version": "1.1.2-alpha.20221107.4",
"version": "1.1.2-alpha.20230209.1",
"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

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