all files / scour/utilities/ indexed_map.js

100% Statements 9/9
100% Branches 2/2
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13     26× 26×      
const forEach = require('./each')
 
module.exports = function indexedMap (each, fn) {
  /* istanbul ignore next */
  if (typeof each !== 'function') each = forEach.bind(this, each)
  const result = {}
  each(function () {
    const item = fn.apply(this, arguments)
    result[item[0]] = item[1]
  })
  return result
}