@therms/web-js
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -0,1 +1,8 @@ | ||
# [1.6.0](http://bitbucket.org/thermsio/web-js/compare/v1.5.0...v1.6.0) (2022-01-16) | ||
### Features | ||
* **PromiseController:** allow no timeout in ctor ([d0c7a39](http://bitbucket.org/thermsio/web-js/commits/d0c7a39bb48b1b73bdf33f14efb98ef734490afb)) | ||
# [1.5.0](http://bitbucket.org/thermsio/web-js/compare/v1.4.0...v1.5.0) (2022-01-16) | ||
@@ -2,0 +9,0 @@ |
@@ -439,7 +439,14 @@ 'use strict'; | ||
promise; | ||
constructor(timeout) { | ||
/** | ||
* The default promise timeout is 30sec, if there is no need for a timeout fail-safe, pass "false" | ||
* @param timeout | ||
*/ | ||
constructor(timeout = DEFAULT_TIMEOUT) { | ||
this.promise = new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => { | ||
reject(new PromiseTimeoutError('PromiseWraper timeout')); | ||
}, timeout || DEFAULT_TIMEOUT); | ||
let timer; | ||
if (timeout > 0) { | ||
timer = setTimeout(() => { | ||
reject(new PromiseTimeoutError('PromiseWraper timeout')); | ||
}, timeout); | ||
} | ||
this.rejectPromise = (arg) => { | ||
@@ -446,0 +453,0 @@ clearTimeout(timer); |
@@ -10,5 +10,9 @@ export declare class PromiseTimeoutError extends Error { | ||
readonly promise: Promise<T>; | ||
constructor(timeout?: number); | ||
/** | ||
* The default promise timeout is 30sec, if there is no need for a timeout fail-safe, pass "false" | ||
* @param timeout | ||
*/ | ||
constructor(timeout?: boolean | number); | ||
reject: (rejectReturnValue?: E) => any; | ||
resolve: (resolveReturnValue: T) => void; | ||
} |
@@ -11,7 +11,14 @@ const DEFAULT_TIMEOUT = 30000; | ||
promise; | ||
constructor(timeout) { | ||
/** | ||
* The default promise timeout is 30sec, if there is no need for a timeout fail-safe, pass "false" | ||
* @param timeout | ||
*/ | ||
constructor(timeout = DEFAULT_TIMEOUT) { | ||
this.promise = new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => { | ||
reject(new PromiseTimeoutError('PromiseWraper timeout')); | ||
}, timeout || DEFAULT_TIMEOUT); | ||
let timer; | ||
if (timeout > 0) { | ||
timer = setTimeout(() => { | ||
reject(new PromiseTimeoutError('PromiseWraper timeout')); | ||
}, timeout); | ||
} | ||
this.rejectPromise = (arg) => { | ||
@@ -18,0 +25,0 @@ clearTimeout(timer); |
{ | ||
"name": "@therms/web-js", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Common web/JS tools & utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
73810
1167