New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-co

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-co - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

cargo.js

16

eachLimit.js
"use strict";
const setImmediate = require('./setImmediate');
const values = require('mout/object/values');
const keys = require('mout/object/keys');
module.exports = function *(series, n, thunk, ctx) {
var n = Math.min(n || 5, series.length);
var isArray = Array.isArray(series);
var iterateeSource = isArray ? series: values(series);
var iterateeKeys = keys(series)
var n = Math.min(n || 5, iterateeSource.length);
var ret = isArray ? [] : {};
var ret = [];
var index = 0;

@@ -21,3 +13,3 @@ var cancel = false;

var next = function *() {
if (index >= iterateeSource.length || cancel)
if (index >= series.length || cancel)
return;

@@ -31,3 +23,3 @@

try { //stop replenishing after error
ret[ isArray ? i : iterateeKeys[i] ] = yield thunk.call(ctx || this, iterateeSource[i]);
ret[i] = yield thunk.call(ctx || this, series[i]);
} catch(err) {

@@ -34,0 +26,0 @@ cancel = true;

@@ -6,4 +6,4 @@ "use strict";

module.exports = function *(series, thunk, ctx) {
yield eachOfLimit(series, Object.keys(series).length, thunk, ctx);
return yield eachOfLimit(series, Object.keys(series).length, thunk, ctx);
};

@@ -5,7 +5,9 @@ "use strict";

module.exports = function *(series, n, thunk, ctx){
module.exports = function *(series, n, thunk, ctx) {
var res = {};
yield eachLimit(Object.keys(series), n, function* (k){
yield thunk(series[k], k);
res[k] = yield thunk(series[k], k);
}, ctx);
return res;
};
{
"name": "async-co",
"version": "1.4.0",
"version": "1.5.0",
"description": "Control flow for co with async.js (v2) signatures",

@@ -29,5 +29,3 @@ "main": "index.js",

"license": "ISC",
"dependencies": {
"mout": "^1.0.0"
},
"dependencies": {},
"devDependencies": {

@@ -38,2 +36,3 @@ "expect.js": "^0.3.1",

"mocha-plugin-co": "^1.0.0",
"mout": "^1.0.0",
"nyks": "^3.1.1"

@@ -40,0 +39,0 @@ },

Control flow ala ES7 async/await using ES6 generator (thanks to [tj/co](https://github.com/tj/co)) with async.js (v2) signatures
[![Build Status](https://travis-ci.org/131/async-co.svg?branch=master)](https://travis-ci.org/131/async-co)
[![Coverage Status](https://coveralls.io/repos/github/131/async-co/badge.svg?branch=master)](https://coveralls.io/github/131/async-co?branch=master)
[![Version](https://img.shields.io/npm/v/async-co.svg)](https://www.npmjs.com/package/async-co)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
# Motivation

@@ -10,7 +17,3 @@ [async-co](https://github.com/131/async-co) provide javascript async/await (through ES6 generator & co) equivalent signatures of the excellent [async](https://github.com/caolan/async) workflow library.

[![Build Status](https://travis-ci.org/131/async-co.svg?branch=master)](https://travis-ci.org/131/async-co)
[![Coverage Status](https://coveralls.io/repos/github/131/async-co/badge.svg?branch=master)](https://coveralls.io/github/131/async-co?branch=master)
[![Version](https://img.shields.io/npm/v/async-co.svg)](https://www.npmjs.com/package/async-co)
**async-co** is not a wrapper on **async**, but rather leverages the full potential of native async/await & promises contract. Code tend to be small & very efficient (far more simplier than using callbacks), just give [async-co/queue.js](https://github.com/131/async-co/blob/master/queue.js) a look

@@ -20,5 +23,6 @@

## Addition to the async library signatures / promise pooling
Per design, it's easy to "throttle" a function that return a Promise ; checkout the "throttle" API for a way to make an ultra simple http request pooling.
* Generator cannot use arrow function binding style, yet it might be usefull to bind async-co closure, therefore, you can use an extra optional args to all signature to set generator binding context. (i.e. as in native [.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) )
* Per design, it's easy to "throttle" a function that return a Promise ; checkout the "throttle" API for a way to make an ultra simple http request pooling.
* async logic allow async/each to iterate through array AND objects. Per design sanify, async-co does not. Use each/eachLimit/eachSeries for array, eachOf/eachOfLimit/eachOfSeries for collections.
# API

@@ -25,0 +29,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