0.1.1 • Published 9 years ago

q-tools v0.1.1

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

q-tools

Extends Q with map and each methods.

Allows execution of a particular function for every value in an array. If the array contains promises the supplied function will not be called until all promises have been resolved.

map

map returns an array with the results of calling fn for each item in the array.

function double(x) {
    return x * 2;
}

var doubled = Q.map(original, double);

// if you want to do parallel processing use mapAsync instead.
var doubledParallel = Q.mapAsync(original, double);

each

each returns the original array after having called fn for each item. Use this method instead of map if you don’t need the transformed values.

function double(x) {
    return x * 2;
}

Q.each(original, double);

// process `original` in parallell
Q.eachAsync(original, double);
0.1.1

9 years ago

0.1.0

9 years ago