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.22 to 2.11.23

7

dist/browser/forget.js

@@ -1,4 +0,3 @@

// src/forget.ts
import { delay } from "@xylabs/delay";
var ForgetPromise = class {
class ForgetPromise {
static activeForgets = 0;

@@ -52,4 +51,4 @@ static get active() {

}
};
var forget = (promise, timeout) => {
}
const forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);

@@ -56,0 +55,0 @@ };

@@ -1,56 +0,2 @@

// src/forget.ts
import { delay } from "@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 delay(interval);
if (timeoutRemaining !== void 0) {
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 (timeout) {
const timeoutFunc = async () => {
await 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;
});
}
};
var forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);
};
import { forget, ForgetPromise } from "./forget";
export {

@@ -57,0 +3,0 @@ ForgetPromise,

@@ -19,2 +19,4 @@ "use strict";

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/forget.ts
var forget_exports = {};

@@ -27,3 +29,3 @@ __export(forget_exports, {

var import_delay = require("@xylabs/delay");
class ForgetPromise {
var ForgetPromise = class {
static activeForgets = 0;

@@ -77,4 +79,4 @@ static get active() {

}
}
const forget = (promise, timeout) => {
};
var forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);

@@ -81,0 +83,0 @@ };

@@ -19,9 +19,66 @@ "use strict";

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
ForgetPromise: () => import_forget.ForgetPromise,
forget: () => import_forget.forget
ForgetPromise: () => ForgetPromise,
forget: () => forget
});
module.exports = __toCommonJS(src_exports);
var import_forget = require("./forget");
// 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;
}
}
}
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?.();
}
};
promises.push(timeoutFunc());
}
const all = Promise.race(promises);
all.then(() => {
return;
}).catch(() => {
return;
});
}
};
var forget = (promise, timeout) => {
ForgetPromise.forget(promise, timeout);
};
// Annotate the CommonJS export names for ESM import in node:

@@ -28,0 +85,0 @@ 0 && (module.exports = {

@@ -42,7 +42,7 @@ {

"dependencies": {
"@xylabs/delay": "~2.11.22"
"@xylabs/delay": "~2.11.23"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "^3.0.70",
"@xylabs/tsconfig": "^3.0.70",
"@xylabs/ts-scripts-yarn3": "^3.0.72",
"@xylabs/tsconfig": "^3.0.72",
"typescript": "^5.2.2"

@@ -58,3 +58,3 @@ },

"sideEffects": false,
"version": "2.11.22"
"version": "2.11.23"
}

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

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

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