Socket
Socket
Sign inDemoInstall

co-rega-foreach

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    co-rega-foreach

Run generator function as Array.prototype.forEach callback.


Version published
Weekly downloads
1
Maintainers
1
Install size
28.4 kB
Created
Weekly downloads
 

Readme

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

Last updated on 24 Jul 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc