all files / scour/utilities/ map_object.js

100% Statements 8/8
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9      
const forEach = require('./each')
 
module.exports = function mapObject (each, fn) {
  if (typeof each !== 'function') each = forEach.bind(this, each)
  const result = {}
  each(function (val, key) { result[key] = fn.apply(this, arguments) })
  return result
}