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

co-rega-foreach

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-rega-foreach

Run generator function as Array.prototype.forEach callback.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

co-rega-foreach

Run generator function as Array.prototype.forEach callback.

Usage

Basic

'use strict';
var co = require('co');
var co_foreach = require('co-rega-foreach');

// If callback is normal func, run with original forEach.
[1, 2, 3].forEach(function(num) {
  console.log('Number is %d.', num);
});

co(function*() {
  var request = require('co-request');

  // If callback is generator func, run with co-rega-foreach.
  yield [1, 2, 3].forEach(function*(num) {
    console.log('Number is %d.', num);
    var res = yield request.get('http://example.com/#' + num);
    console.log('StatusCode : %d', res.statusCode);
  });
  process.exit();
});

Switch between original and co-rega-foreach

'use strict';
var co = require('co');

// co-rega-foreach is enabled.
var co_foreach = require('co-rega-foreach');

// co-rega-foreach is disabled.
co_foreach.disabled();

// co-rega-foreach is enabled.
co_foreach.enabled();

LICENSE

The MIT License (MIT)

Keywords

FAQs

Package last updated on 24 Jul 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