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

@mongodb-js/compass-utils

Package Overview
Dependencies
Maintainers
33
Versions
478
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongodb-js/compass-utils - npm Package Compare versions

Comparing version 0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7 to 0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3

dist/electron.d.ts

14

dist/cancellable-promise.d.ts
declare class AbortError extends Error {
constructor();
constructor(message?: string);
name: string;
}
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

72

dist/cancellable-promise.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cancellableWait = exports.raceWithAbort = exports.isCancelError = exports.createCancelError = void 0;
exports.cancellableWait = exports.raceWithAbort = exports.isCancelError = exports.createCancelError = exports.throwIfAborted = void 0;
class AbortError extends Error {
constructor() {
super('This operation was aborted');
constructor(message) {
super(message ?? 'This operation was aborted');
this.name = 'AbortError';
}
}
const createCancelError = () => {
var _a;
const throwIfAborted = (signal) => {
if (signal?.aborted) {
throw signal.reason ?? (0, exports.createCancelError)();
}
};
exports.throwIfAborted = throwIfAborted;
const createCancelError = (message) => {
const controller = new AbortController();
controller.abort();
return (_a = controller.signal.reason) !== null && _a !== void 0 ? _a : 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);
};
exports.createCancelError = createCancelError;
function isCancelError(error) {
return (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
return error?.name === 'AbortError';
}
exports.isCancelError = isCancelError;
function abortablePromise(abortSignal, successSignal) {
var _a;
if (abortSignal.aborted) {
return Promise.reject((_a = abortSignal.reason) !== null && _a !== void 0 ? _a : (0, exports.createCancelError)());
}
let reject;
const promise = new Promise(function (_resolve, _reject) {
reject = _reject;
});
const abort = () => {
successSignal.removeEventListener('abort', succeed);
reject((0, exports.createCancelError)());
};
const succeed = () => {
abortSignal.removeEventListener('abort', abort);
};
abortSignal.addEventListener('abort', abort, { once: true });
successSignal.addEventListener('abort', succeed, { once: true });
return promise;
}
async function raceWithAbort(promise, signal) {
var _a;
if (signal.aborted) {
return Promise.reject((_a = signal.reason) !== null && _a !== void 0 ? _a : (0, exports.createCancelError)());
return Promise.reject(signal.reason ?? (0, exports.createCancelError)());
}
const successController = new AbortController();
const abortPromise = abortablePromise(signal, successController.signal);
let abortListener;
// We need a promise that will reject as soon as the operation is aborted.
const pendingPromise = new Promise((_resolve, reject) => {
abortListener = () => reject(signal.reason ?? (0, exports.createCancelError)());
signal.addEventListener('abort', abortListener, { once: true });
});
try {
return await Promise.race([abortPromise, promise]);
return await Promise.race([pendingPromise, promise]);
}
finally {
if (!signal.aborted) {
successController.abort();
}
abortListener && signal.removeEventListener('abort', abortListener);
}
}
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) {

@@ -59,0 +61,0 @@ await raceWithAbort(new Promise((resolve) => {

@@ -1,4 +0,5 @@

export { AmpersandMethodOptions, promisifyAmpersandMethod, } from './promisify-ampersand-method';
export { StoragePaths, getStoragePaths } from './get-storage-paths';
export { raceWithAbort, cancellableWait, createCancelError, isCancelError, } from './cancellable-promise';
export type { AmpersandMethodOptions } from './promisify-ampersand-method';
export { promisifyAmpersandMethod } from './promisify-ampersand-method';
export { getAppName, getStoragePath, getAppVersion } from './electron';
export { raceWithAbort, cancellableWait, createCancelError, isCancelError, throwIfAborted, } from './cancellable-promise';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCancelError = exports.createCancelError = exports.cancellableWait = exports.raceWithAbort = exports.getStoragePaths = exports.promisifyAmpersandMethod = void 0;
exports.throwIfAborted = exports.isCancelError = exports.createCancelError = exports.cancellableWait = exports.raceWithAbort = exports.getAppVersion = exports.getStoragePath = exports.getAppName = exports.promisifyAmpersandMethod = void 0;
var promisify_ampersand_method_1 = require("./promisify-ampersand-method");
Object.defineProperty(exports, "promisifyAmpersandMethod", { enumerable: true, get: function () { return promisify_ampersand_method_1.promisifyAmpersandMethod; } });
var get_storage_paths_1 = require("./get-storage-paths");
Object.defineProperty(exports, "getStoragePaths", { enumerable: true, get: function () { return get_storage_paths_1.getStoragePaths; } });
var electron_1 = require("./electron");
Object.defineProperty(exports, "getAppName", { enumerable: true, get: function () { return electron_1.getAppName; } });
Object.defineProperty(exports, "getStoragePath", { enumerable: true, get: function () { return electron_1.getStoragePath; } });
Object.defineProperty(exports, "getAppVersion", { enumerable: true, get: function () { return electron_1.getAppVersion; } });
var cancellable_promise_1 = require("./cancellable-promise");

@@ -13,2 +15,3 @@ Object.defineProperty(exports, "raceWithAbort", { enumerable: true, get: function () { return cancellable_promise_1.raceWithAbort; } });

Object.defineProperty(exports, "isCancelError", { enumerable: true, get: function () { return cancellable_promise_1.isCancelError; } });
Object.defineProperty(exports, "throwIfAborted", { enumerable: true, get: function () { return cancellable_promise_1.throwIfAborted; } });
//# sourceMappingURL=index.js.map
{
"name": "@mongodb-js/compass-utils",
"productName": "compass-utils Plugin",
"description": "Utilities for MongoDB Compass Development",

@@ -17,3 +16,3 @@ "author": {

"homepage": "https://github.com/mongodb-js/compass",
"version": "0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7",
"version": "0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3",
"repository": {

@@ -39,3 +38,3 @@ "type": "git",

"bootstrap": "npm run compile",
"prepublishOnly": "npm run compile",
"prepublishOnly": "npm run compile && compass-scripts check-exports-exist",
"compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",

@@ -46,19 +45,16 @@ "typecheck": "tsc -p tsconfig-lint.json --noEmit",

"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "depcheck",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"test": "mocha",
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
"test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
"test-watch": "npm run test -- --watch",
"test-ci": "npm run test-cov",
"reformat": "npm run prettier -- --write ."
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"dependencies": {
"@electron/remote": "^2.0.8"
},
"devDependencies": {
"@mongodb-js/eslint-config-compass": "0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7",
"@mongodb-js/mocha-config-compass": "0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7",
"@mongodb-js/prettier-config-compass": "0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7",
"@mongodb-js/tsconfig-compass": "0.0.0-next-92d0020f1616b24273dd45bcadc1f36b47a690d7",
"@mongodb-js/eslint-config-compass": "0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3",
"@mongodb-js/mocha-config-compass": "0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3",
"@mongodb-js/prettier-config-compass": "0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3",
"@mongodb-js/tsconfig-compass": "0.0.0-next-9393cb0d5342c1522d7921ddb868725b33e230a3",
"@types/chai": "^4.2.21",

@@ -71,9 +67,13 @@ "@types/mocha": "^9.0.0",

"gen-esm-wrapper": "^1.1.0",
"mocha": "^8.4.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"sinon": "^9.2.3",
"typescript": "^4.8.3"
"typescript": "^5.0.4"
},
"gitHead": "92d0020f1616b24273dd45bcadc1f36b47a690d7"
"dependencies": {
"@electron/remote": "^2.1.2",
"electron": "^30.5.1"
},
"gitHead": "9393cb0d5342c1522d7921ddb868725b33e230a3"
}

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