Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asyncbox

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncbox - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

20

build/lib/asyncbox.js

@@ -18,2 +18,3 @@ "use strict";

exports.waitForCondition = waitForCondition;
exports.longSleep = longSleep;

@@ -28,2 +29,4 @@ require("source-map-support/register");

const LONG_SLEEP_THRESHOLD = 5000;
async function sleep(ms) {

@@ -33,2 +36,17 @@ return await _bluebird.default.delay(ms);

async function longSleep(ms, {
thresholdMs = LONG_SLEEP_THRESHOLD,
intervalMs = 1000
}) {
if (ms < thresholdMs) {
return await sleep(ms);
}
const endAt = Date.now() + ms;
while (Date.now() < endAt) {
await sleep(intervalMs);
}
}
async function retry(times, fn, ...args) {

@@ -174,2 +192,2 @@ let tries = 0;

//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpYi9hc3luY2JveC5qcyJdLCJuYW1lcyI6WyJzbGVlcCIsIm1zIiwiQiIsImRlbGF5IiwicmV0cnkiLCJ0aW1lcyIsImZuIiwiYXJncyIsInRyaWVzIiwiZG9uZSIsInJlcyIsImVyciIsInJldHJ5SW50ZXJ2YWwiLCJzbGVlcE1zIiwiY291bnQiLCJ3cmFwcGVkIiwiZSIsInBhcmFsbGVsIiwicHJvbWlzZXMiLCJhbGwiLCJub2RlaWZ5IiwicHJvbWlzZXkiLCJjYiIsInJlc29sdmUiLCJub2RlaWZ5QWxsIiwicHJvbWlzZXlNYXAiLCJjYk1hcCIsIm5hbWUiLCJfY2IiLCJzbGljZSIsImFzeW5jaWZ5IiwiYXN5bmNtYXAiLCJjb2xsIiwibWFwcGVyIiwicnVuSW5QYXJhbGxlbCIsIm1hcCIsIm5ld0NvbGwiLCJpdGVtIiwicHVzaCIsImFzeW5jZ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G4gICAgICA6IG5ldyBFcnJvcihgQ29uZGl0aW9uIHVubWV0IGFmdGVyICR7d2FpdGVkfSBtcy4gVGltaW5nIG91dC5gKTtcbiAgfTtcbiAgcmV0dXJuIGF3YWl0IHNwaW4oKTtcbn1cblxuZXhwb3J0IHtcbiAgc2xlZXAsIHJldHJ5LCBub2RlaWZ5LCBub2RlaWZ5QWxsLCByZXRyeUludGVydmFsLCBhc3luY2lmeSwgcGFyYWxsZWwsXG4gIGFzeW5jbWFwLCBhc3luY2ZpbHRlciwgd2FpdEZvckNvbmRpdGlvbiwgbG9uZ1NsZWVwLFxufTtcbiJdLCJmaWxlIjoibGliL2FzeW5jYm94LmpzIiwic291cmNlUm9vdCI6Ii4uLy4uIn0=

@@ -7,2 +7,4 @@ // transpile:main

const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
async function sleep (ms) {

@@ -12,2 +14,15 @@ return await B.delay(ms);

async function longSleep (ms, {
thresholdMs = LONG_SLEEP_THRESHOLD,
intervalMs = 1000,
}) {
if (ms < thresholdMs) {
return await sleep(ms);
}
const endAt = Date.now() + ms;
while (Date.now() < endAt) {
await sleep(intervalMs);
}
}
async function retry (times, fn, ...args) {

@@ -136,3 +151,3 @@ let tries = 0;

sleep, retry, nodeify, nodeifyAll, retryInterval, asyncify, parallel,
asyncmap, asyncfilter, waitForCondition
asyncmap, asyncfilter, waitForCondition, longSleep,
};

2

package.json

@@ -9,3 +9,3 @@ {

],
"version": "2.6.0",
"version": "2.7.0",
"author": "jlipps@gmail.com",

@@ -12,0 +12,0 @@ "license": "Apache-2.0",

@@ -26,2 +26,16 @@ asyncbox

### Long Sleep
Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait times. To safely wait for these long times (e.g. in the 5+ minute range), you can use `longSleep`:
```js
import { longSleep } from 'asyncbox';
async function myFn () {
await longSleep(10 * 60 * 1000); // wait for 10 mins
await longSleep(5000, {thresholdMs: 10000}); // wait for 5s. Anything below the thresholdMs will use a single sleep
await longSleep(5000, {intervalMs: 500}); // check the clock every 500ms to see if waiting should stop
}
```
### Retry

@@ -28,0 +42,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc