@appliedblockchain/helpers
Advanced tools
Comparing version 2.8.4 to 2.8.5
@@ -17,4 +17,6 @@ // @flow | ||
timeoutId = setTimeout(() => { | ||
emitter.off(eventName, listener) | ||
listener = null | ||
if (listener) { | ||
emitter.off(eventName, listener) | ||
listener = null | ||
} | ||
reject(errOf( | ||
@@ -25,11 +27,17 @@ 'timeout', `Timeout of ${inspect(timeout)} reached while waiting for conditional event ${inspect(eventName)}.` | ||
listener = emitter.on(eventName, async (...args) => { | ||
listener = async (...args) => { | ||
if (await resultOfPredicate(predicate, ...args)) { | ||
emitter.off(eventName, listener) | ||
listener = null | ||
clearTimeout(timeoutId) | ||
timeoutId = null | ||
if (listener) { | ||
emitter.off(eventName, listener) | ||
listener = null | ||
} | ||
if (timeoutId) { | ||
clearTimeout(timeoutId) | ||
timeoutId = null | ||
} | ||
resolve(...args) | ||
} | ||
}) | ||
} | ||
emitter.on(eventName, listener) | ||
}) | ||
@@ -36,0 +44,0 @@ } |
{ | ||
"name": "@appliedblockchain/helpers", | ||
"version": "2.8.4", | ||
"version": "2.8.5", | ||
"description": "No dependency, single file helpers.", | ||
@@ -10,3 +10,4 @@ "main": "index.js", | ||
"patch": "npm test && npm version patch && git push && git push --tags && npm publish", | ||
"minor": "npm test && npm version minor && git push && git push --tags && npm publish" | ||
"minor": "npm test && npm version minor && git push && git push --tags && npm publish", | ||
"postversion": "changelog > Changelog.md && git add Changelog.md && npm run doc && git add Readme.md && git commit -m \"Updating changelog and readme.\" && git push && git push --tags" | ||
}, | ||
@@ -23,2 +24,3 @@ "keywords": [], | ||
"devDependencies": { | ||
"@appliedblockchain/changelog": "1.1.0", | ||
"@appliedblockchain/eslint-config": "2.6.0", | ||
@@ -25,0 +27,0 @@ "eslint": "5.16.0", |
@@ -25,21 +25,25 @@ ## Summary | ||
- [Parameters](#parameters-4) | ||
- [catchOf](#catchof) | ||
- [Parameters](#parameters-5) | ||
- [defaultCmp](#defaultcmp) | ||
- [Parameters](#parameters-5) | ||
- [Parameters](#parameters-6) | ||
- [eachPromise](#eachpromise) | ||
- [Parameters](#parameters-6) | ||
- [Parameters](#parameters-7) | ||
- [eventuallyTrue](#eventuallytrue) | ||
- [Parameters](#parameters-8) | ||
- [flagOfBoolean](#flagofboolean) | ||
- [Parameters](#parameters-7) | ||
- [Parameters](#parameters-9) | ||
- [Examples](#examples) | ||
- [heightOf](#heightof) | ||
- [Parameters](#parameters-8) | ||
- [Parameters](#parameters-10) | ||
- [hex0xOfNumber](#hex0xofnumber) | ||
- [Parameters](#parameters-9) | ||
- [Parameters](#parameters-11) | ||
- [isLikeDateString](#islikedatestring) | ||
- [Parameters](#parameters-10) | ||
- [Parameters](#parameters-12) | ||
- [isPending](#ispending) | ||
- [Parameters](#parameters-11) | ||
- [Parameters](#parameters-13) | ||
- [isSafeNonNegative](#issafenonnegative) | ||
- [Parameters](#parameters-12) | ||
- [Parameters](#parameters-14) | ||
- [isSafePositive](#issafepositive) | ||
- [Parameters](#parameters-13) | ||
- [Parameters](#parameters-15) | ||
- [makeRetrace](#makeretrace) | ||
@@ -49,10 +53,12 @@ - [noop](#noop) | ||
- [shSync](#shsync) | ||
- [Parameters](#parameters-14) | ||
- [Parameters](#parameters-16) | ||
- [sortedDifference](#sorteddifference) | ||
- [Parameters](#parameters-15) | ||
- [Parameters](#parameters-17) | ||
- [sortedIntersection](#sortedintersection) | ||
- [Parameters](#parameters-16) | ||
- [Parameters](#parameters-18) | ||
- [defaultTimeout](#defaulttimeout) | ||
- [spread](#spread) | ||
- [Parameters](#parameters-17) | ||
- [Parameters](#parameters-19) | ||
- [stopOfMonitor](#stopofmonitor) | ||
- [Parameters](#parameters-20) | ||
@@ -108,2 +114,11 @@ ### addressOfPrivateKey | ||
### catchOf | ||
#### Parameters | ||
- `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `result` **T** | ||
Returns **function (error: [Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)): T** | ||
### defaultCmp | ||
@@ -133,2 +148,14 @@ | ||
### eventuallyTrue | ||
Retries up to `n` times (roughtly seconds) call to `f` waiting for `true` result, which breaks the loop and returns | ||
`true`. If `f` didn't return `true` throws last result value. | ||
#### Parameters | ||
- `f` **function (): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<R>** | ||
- `n` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (optional, default `30`) | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<(`true` | R)>** | ||
### flagOfBoolean | ||
@@ -211,2 +238,3 @@ | ||
Captures extra stack trace, usage `await foo().catch(makeRetrace())`. | ||
`err` argument is being modified with new stack value. | ||
@@ -275,2 +303,14 @@ ### noop | ||
### stopOfMonitor | ||
Creates monitor similar to `setInterval` but allows single execution at a time only. Concurrent invocation attempts | ||
are ignored. | ||
#### Parameters | ||
- `f` **function (): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<any>** | ||
- `milliseconds` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (optional, default `1*1000`) | ||
Returns **any** stop function. | ||
## License | ||
@@ -277,0 +317,0 @@ |
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
123451
111
3318
321
4