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

@xylabs/forget

Package Overview
Dependencies
Maintainers
7
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/forget - npm Package Compare versions

Comparing version 2.11.0 to 2.11.1

dist/forget.js

67

dist/index.js
'use strict';
var delay = require('@xylabs/delay');
var forget = require('./forget.js');
require('@xylabs/delay');
class ForgetPromise {
static activeForgets = 0;
static get active() {
return this.activeForgets > 0;
}
static async awaitInactive(interval = 100, timeout) {
let timeoutRemaining = timeout;
while (this.active) {
await delay.delay(interval);
if (timeoutRemaining !== undefined) {
timeoutRemaining -= interval;
if (timeoutRemaining <= 0) {
return this.activeForgets;
}
}
}
return 0;
}
//used to explicitly launch an async function (or Promise) with awaiting it
static forget(promise, timeout) {
let completed = false;
this.activeForgets++;
const promiseWrapper = async () => {
await promise
.then(() => {
this.activeForgets--;
completed = true;
})
.catch(() => {
this.activeForgets--;
completed = true;
});
};
const promises = [promiseWrapper()];
//if there is a timeout, add it to the race
if (timeout) {
const timeoutFunc = async () => {
await delay.delay(timeout.delay);
if (!completed) {
console.log(`forget promise timeout out after ${timeout.delay}ms [Cancelling]`);
timeout.cancel?.();
}
};
promises.push(timeoutFunc());
}
const all = Promise.race(promises);
all
.then(() => {
return;
})
.catch(() => {
return;
});
}
}
//used to explicitly launch an async function (or Promise) with awaiting it
const forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);
};
exports.ForgetPromise = ForgetPromise;
exports.forget = forget;
exports.ForgetPromise = forget.ForgetPromise;
exports.forget = forget.forget;
//# sourceMappingURL=index.js.map

@@ -51,7 +51,7 @@ {

"dependencies": {
"@xylabs/delay": "~2.11.0"
"@xylabs/delay": "~2.11.1"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.15",
"@xylabs/tsconfig": "^3.0.0-rc.15"
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.16",
"@xylabs/tsconfig": "^3.0.0-rc.16"
},

@@ -66,3 +66,3 @@ "publishConfig": {

"sideEffects": false,
"version": "2.11.0"
"version": "2.11.1"
}

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