<commit_before>const Promise = require('any-promise')
const test = require('tape')
const each = require('./')

test('promise-each should assert input types', function (t) {
  t.plan(1)
  t.throws(each.bind(null, 123))
})

test('should call a fn for each value in arr', function (t) {
  t.plan(2)

  var indexes = []
  var values = []

  Promise.resolve([1, 2, 3])
    .then(each(eachFn))
    .then(checkFn)
    .catch(handleErr)

  function eachFn (val, i) {
    indexes.push(i)
    return values.push(val)
  }

  function checkFn (val) {
    t.deepEqual([0, 1, 2], indexes)
    t.deepEqual([1, 2, 3], values)
  }

  function handleErr () {
    t.fail('catch')
  }
})

test('should call n when n=1', function (t) {
  t.plan(1)

  Promise.resolve(1)
    .then(each(eachFn))
    .then(function () {t.pass('ok')})

  function eachFn () {
    return arguments
  }
})

test('should not return values', function (t) {
  t.plan(1)<commit_msg>fixed backwards `deepEqual`<commit_after>const Promise = require('any-promise')
const test = require('tape')
const each = require('./')

test('promise-each should assert input types', function (t) {
  t.plan(1)
  t.throws(each.bind(null, 123))
})

test('should call a fn for each value in arr', function (t) {
  t.plan(2)

  var indexes = []
  var values = []

  Promise.resolve([1, 2, 3])
    .then(each(eachFn))
    .then(checkFn)
    .catch(handleErr)

  function eachFn (val, i) {
    indexes.push(i)
    return values.push(val)
  }

  function checkFn (val) {
    t.deepEqual(indexes, [0, 1, 2])
    t.deepEqual(values, [1, 2, 3])
  }

  function handleErr () {
    t.fail('catch')
  }
})

test('should call n when n=1', function (t) {
  t.plan(1)

  Promise.resolve(1)
    .then(each(eachFn))
    .then(function () {t.pass('ok')})

  function eachFn () {
    return arguments
  }
})

test('should not return values', function (t) {
  t.plan(1)
{'fraction_non_alphanumeric': 0.1751592356687898, 'fraction_numerical': 0.01910828025477707, 'mean_word_length': 3.235955056179775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1097790', 'n_tokens_mistral': 730, 'n_tokens_neox': 693, 'n_words': 171}