🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
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.

latest
Source
npmnpm
Version
0.1.0
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

co

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