<commit_before>/* eslint-env node, jest */
const { partition, range } = require('iter-tools')

describe('partition', function () {
  describe('evens and odds', function () {
    const isEven = n => n % 2 === 0

    it('empty iterable', function () {
      const [evens, odds] = partition(isEven, [])

      expect([
        Array.from(evens),
        Array.from(odds)
      ]).toEqual([[], []])
    })

    it('range(10)', function () {
      const [evens, odds] = partition(isEven, range(10))

      expect([
        Array.from(evens),
        Array.from(odds)
      ]).toEqual([
        [0, 2, 4, 6, 8],
        [1, 3, 5, 7, 9]
      ])
    })
  })
})<commit_msg>Test if partition calls func once for each item<commit_after>/* eslint-env node, jest */
const { partition, range } = require('iter-tools')

describe('partition', function () {
  describe('evens and odds', function () {
    const isEven = n => n % 2 === 0

    it('empty iterable', function () {
      const [evens, odds] = partition(isEven, [])

      expect([
        Array.from(evens),
        Array.from(odds)
      ]).toEqual([[], []])
    })

    it('range(10)', function () {
      const [evens, odds] = partition(isEven, range(10))

      expect([
        Array.from(evens),
        Array.from(odds)
      ]).toEqual([
        [0, 2, 4, 6, 8],
        [1, 3, 5, 7, 9]
      ])
    })

    it('calls func once for each item', function () {
      const func = jest.fn(isEven)
      const [evens, odds] = partition(func, range(10))
      Array.from(evens)
      Array.from(odds)
      expect(func.mock.calls).toEqual(
        Array.from(range(10)).map(x => [x])
      )
    })
  })
})
{'fraction_non_alphanumeric': 0.186819830713422, 'fraction_numerical': 0.02176541717049577, 'mean_word_length': 2.2642998027613412, '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': '902638', 'n_tokens_mistral': 587, 'n_tokens_neox': 549, 'n_words': 132}