Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored how endpoints are defined, added mapObj utility
- Loading branch information
1 parent
c5492f6
commit ee3ce63
Showing
4 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Module dependencies | ||
*/ | ||
|
||
var _ = require('lodash'); | ||
|
||
/** | ||
* _.map for objects, keeps key/value associations | ||
*/ | ||
|
||
module.exports = function mapObj (input, mapper, context) { | ||
return _.reduce(input, function(obj, v, k) { | ||
obj[k] = mapper.call(context, v, k, input); | ||
return obj; | ||
}, {}, context); | ||
}; |