0.0.11 • Published 9 years ago

q-ter v0.0.11

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

q-ter

Q Stuff

Installation

$ npm install --save q-ter

Usage

var $q = require('q-ter');

$q.map(['foo', 'bar', 'baz'], function(word) {
  return word.length;
}).then(function(lengths) {
  console.log(Math.max.apply(Math, lengths));
});

$q.reduce(['foo', 'bar', 'baz'], function(agg, word) {
  return agg + word.length;
}, 0).then(function(agg_length) {
  console.log(agg_length);
});

$q.parallel({
  foo: function() {
    return 'foo';
  },
  bar: function() {
    var fs = require('fs');
    return q.nfcall(fs.readFile('/foo/bar/baz'));
  }
}).then(function(data) {
  console.log(data.foo, data.bar);
});

$q.auto({
  foo: ['bar', function(bar) {
    var q = require('q');
    return q.delay(2000).then(function() {
      return 'foo ' + bar;
    });
  }],
  bar: function() {
    return 'I like bars!';
  }
}).then(function(data) {
  console.log(data.foo, data.bar);
});

var x = 0;
$q.until(function() {
  var q = require('q');
  return q.delay(1000).then(function() {
    x += 1;
  });
}, function() {
  return x === 10;
}).then(function() {
  console.log(x);
});

Methods

$q.until(iterator, predicate)

Runs iterator until predicate returns true.

$q.parallel(config)

Runs all methods in parallel.

$q.auto(config)

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago