Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@fuman/utils

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fuman/utils - npm Package Compare versions

Comparing version
0.0.15
to
0.0.16
+36
-0
async/deferred.cjs

@@ -14,2 +14,38 @@ "use strict";

}
class DeferredTracked {
#resolve;
#reject;
promise;
status;
constructor() {
this.status = { type: "pending" };
this.promise = new Promise((res, rej) => {
this.#resolve = res;
this.#reject = rej;
});
}
resolve(value) {
if (this.status.type !== "pending") return;
this.status = { type: "fulfilled", value };
this.#resolve(value);
}
reject(reason) {
if (this.status.type !== "pending") return;
this.status = { type: "rejected", reason };
this.#reject(reason);
}
get result() {
if (this.status.type === "fulfilled") {
return this.status.value;
}
return void 0;
}
get error() {
if (this.status.type === "rejected") {
return this.status.reason;
}
return void 0;
}
}
exports.Deferred = Deferred;
exports.DeferredTracked = DeferredTracked;

@@ -7,1 +7,19 @@ export declare class Deferred<T = void> {

}
export declare class DeferredTracked<T = void> {
#private;
readonly promise: Promise<T>;
readonly status: {
type: 'pending';
} | {
type: 'fulfilled';
value: T;
} | {
type: 'rejected';
reason: unknown;
};
constructor();
resolve(value: T): void;
reject(reason: unknown): void;
get result(): T | undefined;
get error(): unknown | undefined;
}

@@ -7,1 +7,19 @@ export declare class Deferred<T = void> {

}
export declare class DeferredTracked<T = void> {
#private;
readonly promise: Promise<T>;
readonly status: {
type: 'pending';
} | {
type: 'fulfilled';
value: T;
} | {
type: 'rejected';
reason: unknown;
};
constructor();
resolve(value: T): void;
reject(reason: unknown): void;
get result(): T | undefined;
get error(): unknown | undefined;
}
+37
-1

@@ -12,4 +12,40 @@ class Deferred {

}
class DeferredTracked {
#resolve;
#reject;
promise;
status;
constructor() {
this.status = { type: "pending" };
this.promise = new Promise((res, rej) => {
this.#resolve = res;
this.#reject = rej;
});
}
resolve(value) {
if (this.status.type !== "pending") return;
this.status = { type: "fulfilled", value };
this.#resolve(value);
}
reject(reason) {
if (this.status.type !== "pending") return;
this.status = { type: "rejected", reason };
this.#reject(reason);
}
get result() {
if (this.status.type === "fulfilled") {
return this.status.value;
}
return void 0;
}
get error() {
if (this.status.type === "rejected") {
return this.status.reason;
}
return void 0;
}
}
export {
Deferred
Deferred,
DeferredTracked
};

@@ -41,2 +41,3 @@ "use strict";

exports.Deferred = deferred.Deferred;
exports.DeferredTracked = deferred.DeferredTracked;
exports.Emitter = emitter.Emitter;

@@ -43,0 +44,0 @@ exports.AggregateError = pool.AggregateError;

+2
-1

@@ -9,3 +9,3 @@ import { noop } from "./misc/index.js";

import { ConditionVariable } from "./async/condition-variable.js";
import { Deferred } from "./async/deferred.js";
import { Deferred, DeferredTracked } from "./async/deferred.js";
import { Emitter } from "./async/emitter.js";

@@ -41,2 +41,3 @@ import { AggregateError, asyncPool, parallelMap } from "./async/pool.js";

Deferred,
DeferredTracked,
Deque,

@@ -43,0 +44,0 @@ Emitter,

{
"name": "@fuman/utils",
"type": "module",
"version": "0.0.15",
"version": "0.0.16",
"description": "various utils",

@@ -6,0 +6,0 @@ "license": "MIT",