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

co-foreach

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-foreach

Run generator function as forEach loop callback

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-48.48%
Maintainers
1
Weekly downloads
 
Created
Source

co-foreach

Build Status

Run generator function as forEach loop callback

Installation

npm install co-foreach

Example 1

var forEach = require('co-foreach');

// Every generator callback is wrapped into co function,
// so you can take advantage of all co features
forEach(array, function * (item, idx) {
  // do something awesome with generators
}).then(handleFinish);

Example 2

var forEach = require('co-foreach');
var Q = require('q');
var fs = require('fs');

var files = ['./test/test1.txt', './test/test2.txt'];

// co-foreach is returning promise
forEach(files, function * (file, idx) {
  var content = yield Q.nfcall(fs.readFile, file);
  // do something usefull
}).then(function () {
  // co-foreach is returning promise which is fulfilled
  // after all generator functions are successfully finished
}).catch(function (err) {
  // handle error
});

Example 3

var forEach = require('co-foreach');

// You can also use co-foreach with normal callbacks
forEach(array, function (item, idx) {
});

License

MIT

Keywords

FAQs

Package last updated on 17 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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