Go to file
2015-07-07 23:50:43 -05:00
.gitignore initial commit 2015-07-07 23:42:25 -05:00
index.js initial commit 2015-07-07 23:42:25 -05:00
package.json initial commit 2015-07-07 23:42:25 -05:00
README.md Update README.md 2015-07-07 23:50:43 -05:00

promise-map-object

A fairly common pattern is to use _ to map an array into promises, then to call Q.all on that array. This library takes that idea a little bit further and now allows you to map an object's values through promises.

Usage

var pmo = require("promise-map-object");

var a = {
  foo: { name: "asdf", age: {$gt: 13} },
  bar: { age: {$lte: 13} }
}

pmo(a, function(query) {
  return db(query); //some database query promise, or similar
}).then(function(mappedA) {
  console.log(mappedA); //res.json, or doing something else with it
});