@mongodb-js/compass-utils
Advanced tools
Comparing version 0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921 to 0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c
declare class AbortError extends Error { | ||
constructor(); | ||
constructor(message?: string); | ||
name: string; | ||
} | ||
export declare const throwIfAborted: (signal?: AbortSignal) => void; | ||
export declare const createCancelError: () => AbortError; | ||
export declare const throwIfAborted: (signal?: { | ||
aborted: boolean; | ||
reason?: Error; | ||
}) => void; | ||
export declare const createCancelError: (message?: string) => AbortError; | ||
export declare function isCancelError(error: any): error is AbortError; | ||
export declare function raceWithAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>; | ||
/** | ||
* Returns a promise that waits for a timeout and can be canceled with a signal | ||
* | ||
* @param ms Wait time | ||
* @param signal Abort signal | ||
*/ | ||
export declare function cancellableWait(ms: number, signal: AbortSignal): Promise<void>; | ||
export {}; | ||
//# sourceMappingURL=cancellable-promise.d.ts.map |
@@ -5,4 +5,4 @@ "use strict"; | ||
class AbortError extends Error { | ||
constructor() { | ||
super('This operation was aborted'); | ||
constructor(message) { | ||
super(message ?? 'This operation was aborted'); | ||
this.name = 'AbortError'; | ||
@@ -17,6 +17,16 @@ } | ||
exports.throwIfAborted = throwIfAborted; | ||
const createCancelError = () => { | ||
const createCancelError = (message) => { | ||
const controller = new AbortController(); | ||
controller.abort(); | ||
return controller.signal.reason ?? new AbortError(); | ||
if (message && controller.signal.reason) { | ||
Object.defineProperty(controller.signal.reason, 'message', { | ||
get() { | ||
return message; | ||
}, | ||
configurable: true, | ||
enumerable: true, | ||
}); | ||
} | ||
// .reason is not supported in all electron versions, so use AbortError as a fallback | ||
return controller.signal.reason ?? new AbortError(message); | ||
}; | ||
@@ -33,2 +43,3 @@ exports.createCancelError = createCancelError; | ||
let abortListener; | ||
// We need a promise that will reject as soon as the operation is aborted. | ||
const pendingPromise = new Promise((_resolve, reject) => { | ||
@@ -46,2 +57,8 @@ abortListener = () => reject(signal.reason ?? (0, exports.createCancelError)()); | ||
exports.raceWithAbort = raceWithAbort; | ||
/** | ||
* Returns a promise that waits for a timeout and can be canceled with a signal | ||
* | ||
* @param ms Wait time | ||
* @param signal Abort signal | ||
*/ | ||
async function cancellableWait(ms, signal) { | ||
@@ -48,0 +65,0 @@ await raceWithAbort(new Promise((resolve) => { |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,2 +15,3 @@ exports.getStoragePath = exports.getAppVersion = exports.getAppName = void 0; | ||
catch (e2) { | ||
// eslint-disable-next-line no-console | ||
console.log('Could not load @electron/remote', e1.message, e2.message); | ||
@@ -16,0 +18,0 @@ } |
@@ -16,3 +16,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/compass", | ||
"version": "0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921", | ||
"version": "0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c", | ||
"repository": { | ||
@@ -54,6 +54,6 @@ "type": "git", | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-7b276eedbfde417d8b9171f491efa2632efe6921", | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-7be3eae26fb97b72561c73d043d0505e1992739c", | ||
"@types/chai": "^4.2.21", | ||
@@ -74,5 +74,5 @@ "@types/mocha": "^9.0.0", | ||
"@electron/remote": "^2.1.2", | ||
"electron": "^29.4.3" | ||
"electron": "^30.4.0" | ||
}, | ||
"gitHead": "7b276eedbfde417d8b9171f491efa2632efe6921" | ||
"gitHead": "7be3eae26fb97b72561c73d043d0505e1992739c" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47134
175
+ Addedelectron@30.5.1(transitive)
- Removedelectron@29.4.6(transitive)
Updatedelectron@^30.4.0