@pushrocks/smartpromise
Advanced tools
Comparing version 3.1.6 to 3.1.7
@@ -37,4 +37,5 @@ export interface IResolve<T> { | ||
export declare const map: <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => Promise<any[]>; | ||
export declare const timeoutWrap: <T = any>(promiseArg: Promise<T>, timeoutInMs: number) => Promise<T>; | ||
export declare const timeoutWrap: <T = any>(promiseArg: Promise<T>, timeoutInMsArg: number, rejectArg?: boolean) => Promise<T>; | ||
export declare const timeoutAndContinue: <T = any>(promiseArg: Promise<T>, timeoutInMsArg?: number) => Promise<T>; | ||
export declare const getFirstTrueOrFalse: (promisesArg: Promise<boolean>[]) => Promise<boolean>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getFirstTrueOrFalse = exports.timeoutWrap = exports.map = exports.rejectedPromise = exports.resolvedPromise = exports.defer = exports.Deferred = void 0; | ||
exports.getFirstTrueOrFalse = exports.timeoutAndContinue = exports.timeoutWrap = exports.map = exports.rejectedPromise = exports.resolvedPromise = exports.defer = exports.Deferred = void 0; | ||
class Deferred { | ||
@@ -65,10 +65,18 @@ constructor() { | ||
}; | ||
exports.timeoutWrap = (promiseArg, timeoutInMs) => { | ||
exports.timeoutWrap = async (promiseArg, timeoutInMsArg, rejectArg = true) => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
reject(new Error('timeout')); | ||
}, timeoutInMs); | ||
if (rejectArg) { | ||
reject(new Error('timeout')); | ||
} | ||
else { | ||
resolve(null); | ||
} | ||
}, timeoutInMsArg); | ||
promiseArg.then(resolve, reject); | ||
}); | ||
}; | ||
exports.timeoutAndContinue = async (promiseArg, timeoutInMsArg = 60000) => { | ||
return exports.timeoutWrap(promiseArg, timeoutInMsArg, false); | ||
}; | ||
exports.getFirstTrueOrFalse = async (promisesArg) => { | ||
@@ -88,2 +96,2 @@ const done = exports.defer(); | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJma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UsQ0FBQyxJQUFJLENBQUMsQ0FBQyxTQUFTLEVBQUUsRUFBRTtZQUM1QixJQUFJLFNBQVMsS0FBSyxJQUFJLEVBQUU7Z0JBQ3RCLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7YUFDcEI7UUFDSCxDQUFDLENBQUMsQ0FBQztLQUNKO0lBQ0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxJQUFJLENBQUMsR0FBRyxFQUFFO1FBQ2pDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDdEIsQ0FBQyxDQUFDLENBQUM7SUFDSCxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDdEIsQ0FBQyxDQUFDIn0= |
{ | ||
"name": "@pushrocks/smartpromise", | ||
"private": false, | ||
"version": "3.1.6", | ||
"version": "3.1.7", | ||
"description": "simple promises and Deferred constructs", | ||
@@ -6,0 +6,0 @@ "main": "dist_ts/index.js", |
@@ -87,7 +87,11 @@ export interface IResolve<T> { | ||
export const timeoutWrap = <T = any>(promiseArg: Promise<T>, timeoutInMs: number) => { | ||
export const timeoutWrap = async <T = any>(promiseArg: Promise<T>, timeoutInMsArg: number, rejectArg = true) => { | ||
return new Promise<T>((resolve, reject) => { | ||
setTimeout(() => { | ||
reject(new Error('timeout')); | ||
}, timeoutInMs); | ||
if (rejectArg) { | ||
reject(new Error('timeout')); | ||
} else { | ||
resolve(null); | ||
} | ||
}, timeoutInMsArg); | ||
promiseArg.then(resolve, reject); | ||
@@ -97,2 +101,6 @@ }); | ||
export const timeoutAndContinue = async <T = any>(promiseArg: Promise<T>, timeoutInMsArg = 60000) => { | ||
return timeoutWrap(promiseArg, timeoutInMsArg, false); | ||
} | ||
export const getFirstTrueOrFalse = async (promisesArg: Promise<boolean>[]) => { | ||
@@ -99,0 +107,0 @@ const done = defer<boolean>(); |
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
16819
254