all files / scour/utilities/ map.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   55× 55× 198× 55×    
const forEach = require('./each')
 
module.exports = function map (each, fn) {
  if (typeof each !== 'function') each = forEach.bind(this, each)
  const result = []
  each(function () { result.push(fn.apply(this, arguments)) })
  return result
}