Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
1363aa7957 | |||
095ea36e5d | |||
b6ab079de0 | |||
734d5aca35 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpromise",
|
"name": "@pushrocks/smartpromise",
|
||||||
"version": "3.1.1",
|
"version": "3.1.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpromise",
|
"name": "@pushrocks/smartpromise",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.1.1",
|
"version": "3.1.3",
|
||||||
"description": "simple promises and Deferred constructs",
|
"description": "simple promises and Deferred constructs",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
@ -84,11 +84,11 @@ export const map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => {
|
|||||||
return resultArray;
|
return resultArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const timeoutWrap = (ms, promise) => {
|
export const timeoutWrap = <T = any>(promiseArg: Promise<T>, timeoutInMs: number) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
reject(new Error('timeout'));
|
reject(new Error('timeout'));
|
||||||
}, ms);
|
}, timeoutInMs);
|
||||||
promise.then(resolve, reject);
|
promiseArg.then(resolve, reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user