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

q-flow

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

q-flow

Flow control (loops, arrays, etc) with promises and Q.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
424
increased by2.91%
Maintainers
1
Weekly downloads
 
Created
Source

map

Call fn, which returns a promise, on each item in array, returning new array.


var q = require('q');
require('q-flow'); // extends q

var fn = function (each) {
    return q.when(each + 1);
};

var array = [ 1, 2, 3 ];

q.map(array, fn).then(function (array) {
    expect(array).to.deep.equal([ 2, 3, 4 ]);
});

each

Like map except new array is not created.

find

Find first object in array satisfying the condition returned by the promise returned by fn.

var array = [ 1, 2, 3 ];
q.find(array, function (each) {
    return q.fcall(function () {
        return each === 2;
    });
}).then(function (result) {
    expect(result).to.equal(2);
});

until

Loop until the promise returned by fn returns a truthy value.

q.until(function () {
    return q.fcall(function () {
        /* code which eventually returns true */
    });
}).then(function (each) {
    /* finished */
});

addBack

Allow one to place node-styled callback onto promise. This exits the promise run-loop so that it no longer catches exceptions.

promise.addBack(function (err, result) {
    // gets `err` if failure happened, otherwise `result` is populated
});

Keywords

FAQs

Package last updated on 09 Dec 2013

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