@nodesuite/defer
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -5,10 +5,10 @@ { | ||
"libraries/defer/.eslintrc.js": "da8f1d5b00175fe9df49681a80b909d918ac6736", | ||
"libraries/defer/CHANGELOG.json": "1a786f2b844f3a2ea05c5b3af9e1fb638235dd87", | ||
"libraries/defer/CHANGELOG.md": "4b9aa4908dba59b93f010ba7ac6c082c3d3d4e37", | ||
"libraries/defer/CHANGELOG.json": "452e483128b0499e601e65b238cdd91e527e9921", | ||
"libraries/defer/CHANGELOG.md": "f3a82f54d958fdfe9949999373d0e67b2d2c0325", | ||
"libraries/defer/README.md": "84db0578b100eb3e4e7c0b16c62b9e0ef747115f", | ||
"libraries/defer/config/rig.json": "54137d20557298060eb70cf9e72e9ce1c7b7e130", | ||
"libraries/defer/package.json": "9f172e0014a22208bca66ea1a6f8bee2cbd3032f", | ||
"libraries/defer/package.json": "87f7ae9ac299ee70f761c2bd49507d643b6e1393", | ||
"libraries/defer/src/index.ts": "6c49cf5df04ad71cd9d67b5f02821f29cc0a7b47", | ||
"libraries/defer/src/provider.ts": "b57fbfbd23276f7bd374e7f69ba4b0ce131af456", | ||
"libraries/defer/src/types.ts": "523b7515cf4a7d6fadadc2a6f9c97630c48feb6c", | ||
"libraries/defer/src/provider.ts": "dc3fc200452e1e27d5c6c4acbb90ae7ddde9a0cd", | ||
"libraries/defer/src/types.ts": "7f7453a361e124c2a4c4cfa3f689bcc8b7928859", | ||
"libraries/defer/tsconfig.json": "1e251ae4114c265a4d5c626f2876f5bda17ac3c8" | ||
@@ -15,0 +15,0 @@ }, |
@@ -5,10 +5,10 @@ { | ||
"libraries/defer/.eslintrc.js": "da8f1d5b00175fe9df49681a80b909d918ac6736", | ||
"libraries/defer/CHANGELOG.json": "1a786f2b844f3a2ea05c5b3af9e1fb638235dd87", | ||
"libraries/defer/CHANGELOG.md": "4b9aa4908dba59b93f010ba7ac6c082c3d3d4e37", | ||
"libraries/defer/CHANGELOG.json": "452e483128b0499e601e65b238cdd91e527e9921", | ||
"libraries/defer/CHANGELOG.md": "f3a82f54d958fdfe9949999373d0e67b2d2c0325", | ||
"libraries/defer/README.md": "84db0578b100eb3e4e7c0b16c62b9e0ef747115f", | ||
"libraries/defer/config/rig.json": "54137d20557298060eb70cf9e72e9ce1c7b7e130", | ||
"libraries/defer/package.json": "9f172e0014a22208bca66ea1a6f8bee2cbd3032f", | ||
"libraries/defer/package.json": "87f7ae9ac299ee70f761c2bd49507d643b6e1393", | ||
"libraries/defer/src/index.ts": "6c49cf5df04ad71cd9d67b5f02821f29cc0a7b47", | ||
"libraries/defer/src/provider.ts": "b57fbfbd23276f7bd374e7f69ba4b0ce131af456", | ||
"libraries/defer/src/types.ts": "523b7515cf4a7d6fadadc2a6f9c97630c48feb6c", | ||
"libraries/defer/src/provider.ts": "dc3fc200452e1e27d5c6c4acbb90ae7ddde9a0cd", | ||
"libraries/defer/src/types.ts": "7f7453a361e124c2a4c4cfa3f689bcc8b7928859", | ||
"libraries/defer/tsconfig.json": "1e251ae4114c265a4d5c626f2876f5bda17ac3c8" | ||
@@ -15,0 +15,0 @@ }, |
@@ -5,2 +5,8 @@ { | ||
{ | ||
"version": "0.1.3", | ||
"tag": "@nodesuite/defer_v0.1.3", | ||
"date": "Sat, 17 Sep 2022 01:00:27 GMT", | ||
"comments": {} | ||
}, | ||
{ | ||
"version": "0.1.2", | ||
@@ -7,0 +13,0 @@ "tag": "@nodesuite/defer_v0.1.2", |
# Change Log - @nodesuite/defer | ||
This log was last generated on Sat, 17 Sep 2022 00:22:25 GMT and should not be manually modified. | ||
This log was last generated on Sat, 17 Sep 2022 01:00:27 GMT and should not be manually modified. | ||
## 0.1.3 | ||
Sat, 17 Sep 2022 01:00:27 GMT | ||
_Version update only_ | ||
## 0.1.2 | ||
@@ -6,0 +11,0 @@ Sat, 17 Sep 2022 00:22:25 GMT |
@@ -16,17 +16,10 @@ /** | ||
*/ | ||
interface Deferral<R = void> { | ||
readonly promise: Promise<R>; | ||
readonly resolve: Resolver<R>; | ||
readonly reject: Rejection; | ||
readonly untilResolved: () => Promise<R>; | ||
interface DeferralBuilder<R = void> { | ||
promise: Promise<R>; | ||
resolve: Resolver<R>; | ||
reject: Rejection; | ||
isResolved(): boolean; | ||
untilResolved(): Promise<R>; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
interface Builder<R = void> { | ||
promise?: Promise<R> | undefined; | ||
resolve?: Resolver<R> | undefined; | ||
reject?: Rejection | undefined; | ||
untilResolved?: () => Promise<R>; | ||
} | ||
declare type Deferral<R = void> = Readonly<DeferralBuilder<R>>; | ||
@@ -38,4 +31,4 @@ /** | ||
*/ | ||
declare const defer: <R = void>(callback?: Callback<R>) => Deferral<R>; | ||
declare const defer: <R = void>(callback?: Callback<R>) => Readonly<DeferralBuilder<R>>; | ||
export { Builder, Callback, Deferral, Rejection, Resolver, defer }; | ||
export { Callback, Deferral, DeferralBuilder, Rejection, Resolver, defer }; |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var a=()=>()=>{},n=(o=a())=>{let e={},r=new Promise((s,l)=>{e.resolve=()=>{s(o());},e.reject=l;});return e.promise=r,e.untilResolved=async()=>r,e}; | ||
var n=()=>()=>{},i=(l=n())=>{let r=!1,e={resolve:void 0,reject:void 0,promise:void 0,isResolved:()=>r},o=new Promise((s,a)=>{e.resolve=()=>{r=!0,s(l());},e.reject=a;});return e.promise=o,e.untilResolved=async()=>o,Object.freeze(e)}; | ||
exports.defer = n; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wcm92aWRlci50cyJdLCJuYW1lcyI6WyJOT09QIiwiZGVmZXIiLCJjYWxsYmFjayIsImRlZmVycmFsIiwicHJvbWlzZSIsInJlc29sdmUiLCJyZWplY3QiXSwibWFwcGluZ3MiOiJBQU9BLElBQU1BLEVBQ0osSUFDQSxJQUFNLEdBUUtDLEVBQVEsQ0FDbkJDLEVBQXdCRixFQUFLLElBQ2IsQ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| ||
"name": "@nodesuite/defer", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Deferred Promise resolution tools.", | ||
@@ -31,4 +31,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@nodesuite/eslint-config": "0.1.2", | ||
"@nodesuite/node-rig": "0.1.2", | ||
"@nodesuite/eslint-config": "0.1.3", | ||
"@nodesuite/node-rig": "0.1.3", | ||
"@rushstack/eslint-config": "^3.0.1", | ||
@@ -35,0 +35,0 @@ "@rushstack/heft": "^0.47.9", |
@@ -1,2 +0,2 @@ | ||
import type { Builder, Callback, Deferral } from "./types" | ||
import type { Callback, Deferral, DeferralBuilder } from "./types" | ||
@@ -21,6 +21,15 @@ /** | ||
): Deferral<R> => { | ||
const deferral: Builder<R> = {} | ||
let _isResolved: boolean = false | ||
const deferral: Partial<DeferralBuilder<R>> = { | ||
resolve: undefined, | ||
reject: undefined, | ||
promise: undefined, | ||
isResolved: (): boolean => _isResolved | ||
} | ||
const promise: Promise<R> = new Promise<R>((resolve, reject) => { | ||
deferral.resolve = () => { | ||
_isResolved = true | ||
resolve(callback()) | ||
@@ -35,3 +44,3 @@ } | ||
return deferral as Deferral<R> | ||
return Object.freeze(deferral) as Deferral<R> | ||
} |
@@ -19,22 +19,17 @@ /** | ||
*/ | ||
export interface Deferral<R = void> { | ||
export interface DeferralBuilder<R = void> { | ||
// Original promise to await. | ||
readonly promise: Promise<R> | ||
promise: Promise<R> | ||
// Internal resolve function. | ||
readonly resolve: Resolver<R> | ||
resolve: Resolver<R> | ||
// Internal reject function. | ||
readonly reject: Rejection | ||
reject: Rejection | ||
// Test if deferral has already been resolved. | ||
isResolved(): boolean | ||
// Sugar syntax to avoid using promise object. | ||
readonly untilResolved: () => Promise<R> | ||
untilResolved(): Promise<R> | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
export interface Builder<R = void> { | ||
promise?: Promise<R> | undefined | ||
resolve?: Resolver<R> | undefined | ||
reject?: Rejection | undefined | ||
untilResolved?: () => Promise<R> | ||
} | ||
export type Deferral<R = void> = Readonly<DeferralBuilder<R>> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104282