await-timeout
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -22,4 +22,5 @@ /** | ||
Timeout.sleep = ms => new Timeout().set(ms); | ||
// Static `.set()` helper | ||
Timeout.set = ms => new Timeout().set(ms); | ||
export default Timeout; |
@@ -1,2 +0,2 @@ | ||
/*! await-timeout v0.1.2 */ | ||
/*! await-timeout v0.1.3 */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -127,3 +127,6 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
Timeout.sleep = function (ms) { | ||
// Static `.set()` helper | ||
Timeout.set = function (ms) { | ||
return new Timeout().set(ms); | ||
@@ -130,0 +133,0 @@ }; |
{ | ||
"name": "await-timeout", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A Promise-based API for setTimeout / clearTimeout", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -81,2 +81,3 @@ <div align="center"> | ||
``` | ||
If you need to reject after timeout: | ||
@@ -87,2 +88,3 @@ ```js | ||
``` | ||
Or reject with custom error: | ||
@@ -100,10 +102,5 @@ ```js | ||
If you need to just wait some time: | ||
If you need to just wait some time - use static version of `.set()`: | ||
```js | ||
doAsyncJob() | ||
.then(() => new Timeout().set(1000)); | ||
// or there is static helper shortcut `Timeout.sleep(ms)` | ||
doAsyncJob() | ||
.then(() => Timeout.sleep(1000)); | ||
Timeout.set(1000).then(...); | ||
``` | ||
@@ -116,6 +113,7 @@ | ||
timeout.set(1000) | ||
.then(() => console.log('This will never be called!')); | ||
.then(() => console.log('This will never be called, because timeout is cleared on the next line')); | ||
timeout.clear(); | ||
``` | ||
With [async / await] `.clear()` can be used in `finally` block: | ||
With [ES7 async / await] `.clear()` can be used in `finally` block: | ||
```js | ||
@@ -122,0 +120,0 @@ async function foo() { |
Sorry, the diff of this file is not supported yet
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
252
148