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.10.18 to 2.11.0

dist/forget.d.ts

16

dist/index.d.ts

@@ -1,13 +0,3 @@

interface ForgetTimeoutConfig {
cancel: () => void;
delay: number;
}
declare class ForgetPromise {
static activeForgets: number;
static get active(): boolean;
static awaitInactive(interval?: number, timeout?: number): Promise<number>;
static forget(promise: Promise<unknown>, timeout?: ForgetTimeoutConfig): void;
}
declare const forget: (promise: Promise<unknown>, timeout?: ForgetTimeoutConfig) => void;
export { ForgetPromise, forget as default, forget };
import { forget, ForgetPromise } from './forget';
export { forget, ForgetPromise };
//# sourceMappingURL=index.d.ts.map

@@ -1,92 +0,67 @@

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
'use strict';
// src/index.ts
var src_exports = {};
__export(src_exports, {
ForgetPromise: () => ForgetPromise,
default: () => src_default,
forget: () => forget
});
module.exports = __toCommonJS(src_exports);
var delay = require('@xylabs/delay');
// src/forget.ts
var import_delay = require("@xylabs/delay");
var ForgetPromise = class {
static activeForgets = 0;
static get active() {
return this.activeForgets > 0;
}
static async awaitInactive(interval = 100, timeout) {
let timeoutRemaining = timeout;
while (this.active) {
await (0, import_delay.delay)(interval);
if (timeoutRemaining !== void 0) {
timeoutRemaining -= interval;
if (timeoutRemaining <= 0) {
return this.activeForgets;
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;
}
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 (timeout) {
const timeoutFunc = async () => {
await (0, import_delay.delay)(timeout.delay);
if (!completed) {
console.log(`forget promise timeout out after ${timeout.delay}ms [Cancelling]`);
timeout.cancel?.();
//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());
}
};
promises.push(timeoutFunc());
const all = Promise.race(promises);
all
.then(() => {
return;
})
.catch(() => {
return;
});
}
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);
};
var forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);
};
// src/index.ts
var src_default = forget;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ForgetPromise,
forget
});
//# sourceMappingURL=index.js.map
exports.ForgetPromise = ForgetPromise;
exports.forget = forget;
//# sourceMappingURL=index.js.map

@@ -43,6 +43,2 @@ {

"module": "dist/index.mjs",
"scripts": {
"package-compile": "tsup && publint",
"package-recompile": "tsup && publint"
},
"homepage": "https://xylabs.com",

@@ -56,9 +52,7 @@ "keywords": [

"dependencies": {
"@xylabs/delay": "~2.10.18"
"@xylabs/delay": "~2.11.0"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "^2.19.12",
"@xylabs/tsconfig": "^2.19.12",
"publint": "^0.2.2",
"tsup": "^7.2.0"
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.15",
"@xylabs/tsconfig": "^3.0.0-rc.15"
},

@@ -73,3 +67,3 @@ "publishConfig": {

"sideEffects": false,
"version": "2.10.18"
"version": "2.11.0"
}
import { forget, ForgetPromise } from './forget'
export { forget, ForgetPromise }
// eslint-disable-next-line import/no-default-export
export default forget

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