@pushrocks/smartpromise
Advanced tools
Comparing version 3.0.6 to 3.1.1
@@ -7,2 +7,3 @@ { | ||
"gitzone": { | ||
"projectType": "npm", | ||
"module": { | ||
@@ -9,0 +10,0 @@ "githost": "gitlab.com", |
{ | ||
"name": "@pushrocks/smartpromise", | ||
"private": false, | ||
"version": "3.0.6", | ||
"version": "3.1.1", | ||
"description": "simple promises and Deferred constructs", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"main": "dist_ts/index.js", | ||
"typings": "dist_ts/index.d.ts", | ||
"scripts": { | ||
"test": "(tstest test/)", | ||
"build": "(tsbuild)" | ||
"test": "(tstest test/ --web)", | ||
"build": "(tsbuild --web)" | ||
}, | ||
@@ -24,20 +24,24 @@ "repository": { | ||
"devDependencies": { | ||
"@gitzone/tsbuild": "^2.1.17", | ||
"@gitzone/tstest": "^1.0.24", | ||
"@pushrocks/tapbundle": "^3.0.13", | ||
"@types/node": "^12.7.5", | ||
"tslint": "^5.20.0", | ||
"@gitzone/tsbuild": "^2.1.25", | ||
"@gitzone/tstest": "^1.0.52", | ||
"@pushrocks/tapbundle": "^3.2.9", | ||
"@types/node": "^14.11.8", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0" | ||
}, | ||
"files": [ | ||
"ts/*", | ||
"ts_web/*", | ||
"dist/*", | ||
"dist_web/*", | ||
"dist_ts_web/*", | ||
"assets/*", | ||
"ts/**/*", | ||
"ts_web/**/*", | ||
"dist/**/*", | ||
"dist_*/**/*", | ||
"dist_ts/**/*", | ||
"dist_ts_web/**/*", | ||
"assets/**/*", | ||
"cli.js", | ||
"npmextra.json", | ||
"readme.md" | ||
], | ||
"browserslist": [ | ||
"last 1 chrome versions" | ||
] | ||
} |
@@ -45,3 +45,3 @@ export interface IResolve<T> { | ||
export let defer = <T>() => { | ||
export const defer = <T>() => { | ||
return new Deferred<T>(); | ||
@@ -53,3 +53,3 @@ }; | ||
*/ | ||
export let resolvedPromise = <T>(value?: T): Promise<T> => { | ||
export const resolvedPromise = <T>(value?: T): Promise<T> => { | ||
return Promise.resolve(value); | ||
@@ -61,3 +61,3 @@ }; | ||
*/ | ||
export let rejectedPromise = err => { | ||
export const rejectedPromise = (err) => { | ||
return Promise.reject(err); | ||
@@ -70,9 +70,15 @@ }; | ||
export let map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => { | ||
let promiseArray: Promise<any>[] = []; | ||
let resultArray = []; | ||
for (let item of inputArg) { | ||
let promise: Promise<any> = functionArg(item); | ||
/** | ||
* accepts an array of inputs and a function that accepts the input. | ||
* runs all items with the function and returns the result array when all items have run | ||
* @param inputArg | ||
* @param functionArg | ||
*/ | ||
export const map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => { | ||
const promiseArray: Promise<any>[] = []; | ||
const resultArray = []; | ||
for (const item of inputArg) { | ||
const promise: Promise<any> = functionArg(item); | ||
promiseArray.push(promise); | ||
promise.then(x => { | ||
promise.then((x) => { | ||
resultArray.push(x); | ||
@@ -84,1 +90,10 @@ }); | ||
}; | ||
export const timeoutWrap = (ms, promise) => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
reject(new Error('timeout')); | ||
}, ms); | ||
promise.then(resolve, reject); | ||
}); | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
13094
209
1