<commit_before>var asyncReduce = require('./itera-reduce')

function asyncMap (obj, iterator, done) {
  function mapIterator (acc, val, key, next) {
    iterator(val, key, (err, res) => {
      acc.push(res)
      next(err, acc)
    })
  }

  asyncReduce(obj, [], mapIterator, done)
}

module.exports = asyncMap<commit_msg>update async/itera-map — add logic for objs alpha stage.<commit_after>'use strict'

var asyncReduce = require('./itera-reduce')

function asyncMap (obj, iterator, done) {
  function mapArrIterator (acc, val, key, next) {
    iterator(val, key, (err, res) => {
      acc.push(res)
      next(err, acc)
    })
  }

  function mapObjIterator (acc, val, key, next) {
    iterator(val, key, (err, res) => {
      acc[key] = res
      next(err, acc)
    })
  }

  let seed
  let mapIterator

  if (Array.isArray(obj)) {
    seed = []
    mapIterator = mapArrIterator
  } else {
    seed = {}
    mapIterator = mapObjIterator
  }

  asyncReduce(obj, seed, mapIterator, done)
}

module.exports = asyncMap
{'fraction_non_alphanumeric': 0.1422963689892051, 'fraction_numerical': 0.0, 'mean_word_length': 3.08, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '477114', 'n_tokens_mistral': 352, 'n_tokens_neox': 347, 'n_words': 89}