node-loop

1.0.4 • Public • Published

Node Loop

Build Status

Helper method to loop through an array. Returns a promise.

Install

  $ npm install node-loop

Example

  var people = [{
    id: 1,
    name: "William"
  }, {
    id: 2,
    name: "John"
  }, {
    id: 3,
    name: "Bill"
  }, {
    id: 4,
    name: "John"
  }, {
    id: 5,
    name: "Anne"
  }, {
    id: 6,
    name: "Lucy"
  }];

  function transformName(item, next) {
    setTimeout(function() {
      var data = {
        id: item.id,
        name: item.name.toUpperCase()
      }

      return next(false, data);
    }, 1000);
  }

  loop.promise(people, transformName)
  .then(function(transformed) {
    // do something with your transformed array.
  })
  .fail(function(err) {
    console.log(err);
  })

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    1
  • 1.0.3
    0
  • 1.0.22
    0
  • 1.0.1
    0

Package Sidebar

Install

npm i node-loop

Weekly Downloads

1

Version

1.0.4

License

MIT

Last publish

Collaborators

  • luiselizondo