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

loop

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loop

The promise / subscribe / deferred module of FuturesJS (Ender.JS and Node.JS)

  • 2.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.8K
decreased by-36.43%
Maintainers
1
Weekly downloads
 
Created
Source

loop()

Creates a "safe" asynchronous loop.

core

  • Futures.loop(context=null) - creates a loop object

  • run(function (next), seed [, ...]) - Start the loop

    • next = function (err, data [, ...]) {}
      • next("break") will break the loop
    • seed - the data to start with
  • setTimeout(ms) - Kill the loop if it runs for ms

  • setMaxLoop(count) - Kill the loop if it continues count+1 times

  • setWait(ms) - Wait at least ms before looping again (Browser minimum is 4ms, even if 0 is set)

Note: In a browser each loop will be at least 4ms apart.

Example:

var loop = Futures.loop();

loop.setTimeout(1000);
loop.setMaxLoop(20);

loop.run(function (next, err, data) {
  if (data == 4) {
    next("break");
  }
  data += 1;
  next(undefined, data);
}, 0);

Keywords

FAQs

Package last updated on 13 Jan 2014

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