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.9.2 to 2.9.3

60

build/lib/asyncbox.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sleep = sleep;
exports.retry = retry;
exports.asyncfilter = asyncfilter;
exports.asyncify = asyncify;
exports.asyncmap = asyncmap;
exports.longSleep = longSleep;
exports.nodeify = nodeify;
exports.nodeifyAll = nodeifyAll;
exports.parallel = void 0;
exports.retry = retry;
exports.retryInterval = retryInterval;
exports.asyncify = asyncify;
exports.parallel = parallel;
exports.asyncmap = asyncmap;
exports.asyncfilter = asyncfilter;
exports.sleep = sleep;
exports.waitForCondition = waitForCondition;
exports.longSleep = longSleep;
require("source-map-support/register");
var _bluebird = _interopRequireDefault(require("bluebird"));
var _es6Mapify = require("es6-mapify");
var _lodash = _interopRequireDefault(require("lodash"));

@@ -42,7 +36,5 @@

}
const endAt = Date.now() + ms;
let timeLeft;
let elapsedMs = 0;
do {

@@ -54,3 +46,2 @@ const pre = Date.now();

elapsedMs = elapsedMs + (post - pre);
if (_lodash.default.isFunction(progressCb)) {

@@ -70,6 +61,4 @@ progressCb({

let res = null;
while (!done && tries < times) {
tries++;
try {

@@ -84,3 +73,2 @@ res = await fn(...args);

}
return res;

@@ -91,7 +79,5 @@ }

let count = 0;
let wrapped = async () => {
count++;
let res;
try {

@@ -103,16 +89,11 @@ res = await fn(...args);

}
throw e;
}
return res;
};
return await retry(times, wrapped);
}
const parallel = _bluebird.default.all;
async function parallel(promises) {
return await _bluebird.default.all(promises);
}
exports.parallel = parallel;
function nodeify(promisey, cb) {

@@ -124,4 +105,3 @@ return _bluebird.default.resolve(promisey).nodeify(cb);

let cbMap = {};
for (const [name, fn] of (0, _es6Mapify.mapify)(promiseyMap)) {
for (const [name, fn] of _lodash.default.toPairs(promiseyMap)) {
cbMap[name] = function (...args) {

@@ -133,3 +113,2 @@ const _cb = args.slice(-1)[0];

}
return cbMap;

@@ -146,9 +125,6 @@ }

}
let newColl = [];
for (let item of coll) {
newColl.push(await mapper(item));
}
return newColl;

@@ -159,6 +135,4 @@ }

let newColl = [];
if (runInParallel) {
let bools = await parallel(coll.map(filter));
for (let i = 0; i < coll.length; i++) {

@@ -176,12 +150,10 @@ if (bools[i]) {

}
return newColl;
}
async function waitForCondition(condFn, opts = {}) {
_lodash.default.defaults(opts, {
async function waitForCondition(condFn, options = {}) {
const opts = _lodash.default.defaults(options, {
waitMs: 5000,
intervalMs: 500
});
const debug = opts.logger ? opts.logger.debug.bind(opts.logger) : _lodash.default.noop;

@@ -191,14 +163,10 @@ const error = opts.error;

const endAt = begunAt + opts.waitMs;
const spin = async function spin() {
const result = await condFn();
if (result) {
return result;
}
const now = Date.now();
const waited = now - begunAt;
const remainingTime = endAt - now;
if (now < endAt) {

@@ -209,6 +177,4 @@ debug(`Waited for ${waited} ms so far`);

}
throw error ? _lodash.default.isString(error) ? new Error(error) : error : new Error(`Condition unmet after ${waited} ms. Timing out.`);
};
return await spin();

@@ -218,2 +184,2 @@ }require('source-map-support').install();

//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpYi9hc3luY2JveC5qcyJdLCJuYW1lcyI6WyJMT05HX1NMRUVQX1RIUkVTSE9MRCIsInNsZWVwIiwibXMiLCJCIiwiZGVsYXkiLCJsb25nU2xlZXAiLCJ0aHJlc2hvbGRNcyIsImludGVydmFsTXMiLCJwcm9ncmVzc0NiIiwiZW5kQXQiLCJEYXRlIiwibm93IiwidGltZUxlZnQiLCJlbGFwc2VkTXMiLCJwcmUiLCJwb3N0IiwiXyIsImlzRnVuY3Rpb24iLCJwcm9ncmVzcyIsInJldHJ5IiwidG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0MsS0FBSyxDQUFDdUUsSUFBSSxDQUFDQyxHQUFHLENBQUNkLElBQUksQ0FBQ3ZELFVBQVUsRUFBRW1FLGFBQWEsQ0FBQyxDQUFDO01BQ3ZELE9BQU8sTUFBTUgsSUFBSSxFQUFFO0lBQ3JCO0lBRUEsTUFBTUYsS0FBSyxHQUNOckQsZUFBQyxDQUFDNkQsUUFBUSxDQUFDUixLQUFLLENBQUMsR0FBRyxJQUFJUyxLQUFLLENBQUNULEtBQUssQ0FBQyxHQUFHQSxLQUFLLEdBQzdDLElBQUlTLEtBQUssQ0FBRSx5QkFBd0JMLE1BQU8sa0JBQWlCLENBQUM7RUFDbEUsQ0FBQztFQUNELE9BQU8sTUFBTUYsSUFBSSxFQUFFO0FBQ3JCIn0=
// transpile:main
import B from 'bluebird';
import { mapify } from 'es6-mapify';
import _ from 'lodash';

@@ -9,2 +8,7 @@

/**
* An async/await version of setTimeout
* @param {number} ms
* @returns {Promise<void>}
*/
async function sleep (ms) {

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

/**
* 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`.
*
* sYou can also pass a `progressCb` option which is a callback function that
* receives an object with the properties `elapsedMs`, `timeLeft`, and
* `progress`. This will be called on every wait interval so you can do your
* wait logging or whatever.
* @param {number} ms
* @param {LongSleepOptions} [opts]
* @returns {Promise<void>}
*/
async function longSleep (ms, {

@@ -38,2 +55,10 @@ thresholdMs = LONG_SLEEP_THRESHOLD,

/**
* An async/await way of running a method until it doesn't throw an error
* @template [T=any]
* @param {number} times
* @param {(...args: any[]) => Promise<T>} fn
* @param {...any} args
* @returns {Promise<T?>}
*/
async function retry (times, fn, ...args) {

@@ -57,2 +82,12 @@ let tries = 0;

/**
* You can also use `retryInterval` to add a sleep in between retries. This can
* be useful if you want to throttle how fast we retry.
* @template [T=any]
* @param {number} times
* @param {number} sleepMs
* @param {(...args: any[]) => Promise<T>} fn
* @param {...any} args
* @returns {Promise<T?>}
*/
async function retryInterval (times, sleepMs, fn, ...args) {

@@ -77,6 +112,12 @@ let count = 0;

async function parallel (promises) {
return await B.all(promises);
}
const parallel = B.all;
/**
* Export async functions (Promises) and import this with your ES5 code to use
* it with Node.
* @template [R=any]
* @param {any} promisey
* @param {(err: any, value?: R) => void} cb
* @returns {Promise<R>}
*/
function nodeify (promisey, cb) { // eslint-disable-line promise/prefer-await-to-callbacks

@@ -86,5 +127,11 @@ return B.resolve(promisey).nodeify(cb);

/**
* Node-ify an entire object of `Promise`-returning functions
* @param {Record<string,(...args: any[]) => any>} promiseyMap
* @returns {Record<string,(...args: any[])=>void>}
*/
function nodeifyAll (promiseyMap) {
/** @type {Record<string,(...args: any[])=>void>} */
let cbMap = {};
for (const [name, fn] of mapify(promiseyMap)) {
for (const [name, fn] of _.toPairs(promiseyMap)) {
cbMap[name] = function (...args) {

@@ -99,2 +146,6 @@ const _cb = args.slice(-1)[0];

/**
* @param {(...args: any[]) => any|Promise<any>} fn
* @param {...any} args
*/
function asyncify (fn, ...args) {

@@ -104,2 +155,8 @@ B.resolve(fn(...args)).done();

/**
* Similar to `Array.prototype.map`; runs in serial
* @param {any[]} coll
* @param {(value: any) => any|Promise<any>} mapper
* @returns {Promise<any[]>}
*/
async function asyncmap (coll, mapper, runInParallel = true) {

@@ -117,2 +174,9 @@ if (runInParallel) {

/**
* Similar to `Array.prototype.filter`
* @param {any[]} coll
* @param {(value: any) => any|Promise<any>} filter
* @param {boolean} runInParallel
* @returns {Promise<any[]>}
*/
async function asyncfilter (coll, filter, runInParallel = true) {

@@ -137,4 +201,22 @@ let newColl = [];

async function waitForCondition (condFn, opts = {}) {
_.defaults(opts, {
/**
* Takes a condition (a function returning a boolean or boolean promise), and
* waits until the condition is true.
*
* Throws a `/Condition unmet/` error if the condition has not been satisfied
* within the allocated time, unless an error is provided in the options, as the
* `error` property, which is either thrown itself, or used as the message.
*
* The condition result is returned if it is not falsy. If the condition throws an
* error then this exception will be immediately passed through.
*
* The default options are: `{ waitMs: 5000, intervalMs: 500 }`
* @template T
* @param {() => Promise<T>|T} condFn
* @param {WaitForConditionOptions} [options]
* @returns {Promise<T>}
*/
async function waitForCondition (condFn, options = {}) {
/** @type {WaitForConditionOptions & {waitMs: number, intervalMs: number}} */
const opts = _.defaults(options, {
waitMs: 5000,

@@ -147,2 +229,3 @@ intervalMs: 500,

const endAt = begunAt + opts.waitMs;
/** @returns {Promise<T>} */
const spin = async function spin () {

@@ -173,1 +256,33 @@ const result = await condFn();

};
/**
* Options for {@link waitForCondition}
* @typedef WaitForConditionOptions
* @property {number} [waitMs]
* @property {number} [intervalMs]
* @property {{debug: (...args: any[]) => void}} [logger]
* @property {string|Error} [error]
*/
/**
* Options for {@link longSleep}
* @typedef LongSleepOptions
* @property {number} [thresholdMs]
* @property {number} [intervalMs]
* @property {ProgressCallback?} [progressCb]
*/
/**
* Parameter provided to a {@link ProgressCallback}
* @typedef Progress
* @property {number} elapsedMs
* @property {number} timeLeft
* @property {number} progress
*/
/**
* Progress callback for {@link longSleep}
* @callback ProgressCallback
* @param {Progress} progress
* @returns {void}
*/

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

],
"version": "2.9.2",
"version": "2.9.3",
"author": "jlipps@gmail.com",

@@ -20,5 +20,5 @@ "license": "Apache-2.0",

},
"engines": [
"node"
],
"engines": {
"node": ">=10"
},
"main": "./build/lib/asyncbox.js",

@@ -36,12 +36,12 @@ "bin": {},

"bluebird": "^3.5.1",
"es6-mapify": "^1.1.0",
"lodash": "^4.17.4",
"source-map-support": "^0.5.5"
"source-map-support": "^0.5.5",
"@types/bluebird": "^3.5.37"
},
"scripts": {
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
"prepare": "gulp prepublish",
"prepare": "gulp prepublish && tsc",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"build": "gulp transpile",
"build": "gulp transpile && tsc",
"lint": "gulp eslint",

@@ -51,2 +51,3 @@ "watch": "gulp watch"

"devDependencies": {
"@types/lodash": "^4.14.189",
"ajv": "^6.5.3",

@@ -60,4 +61,6 @@ "appium-gulp-plugins": "^4.0.0",

"should": "^13.2.1",
"sinon": "^11.1.2"
}
"sinon": "^11.1.2",
"typescript": "~4.7.0"
},
"types": "./build/lib/asyncbox.d.ts"
}
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