commit 829366aaafc9be416b56d0150927e092437bf1a3 Author: Kegan Myers Date: Tue Jul 7 23:42:25 2015 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/index.js b/index.js new file mode 100644 index 0000000..bb741ce --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ +var lodash = require("lodash"); +var Q = require("q"); + +function mapObjectPromises(input, func) { + return Q.all(_.map(input, func)).then(function(data) { + return _.zipObject(_.keys(input), data); + }); +} + +module.exports = mapObjectPromises; diff --git a/package.json b/package.json new file mode 100644 index 0000000..09542ec --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "promise-map-object", + "version": "0.0.1", + "description": "A simple helper function to map an object's values via promises", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/terribleplan/promise-map-object.git" + }, + "keywords": [ + "promise", + "object", + "map", + "values" + ], + "author": "Kegan Myers ", + "license": "ISC", + "bugs": { + "url": "https://github.com/terribleplan/promise-map-object/issues" + }, + "homepage": "https://github.com/terribleplan/promise-map-object", + "dependencies": { + "lodash": "^3.10.0", + "q": "^1.4.1" + } +}