Socket
Socket
Sign inDemoInstall

await-timeout

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.1.4

test/specs/timeout.set.test.js

3

index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc