Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / chain-able-deps   js

Repository URL to install this package:

Version: 6.0.4 

/ src / fp / __tests__ / times.ts

import times from '../times'
import identity from '../identity'

describe('times', () => {
  it('takes a map func', () => {
    eq(times(identity, 5), [0, 1, 2, 3, 4])
    eq(times(x => x * 2, 5), [0, 2, 4, 6, 8])
  })

  it('is curried', () => {
    const mapid = times(identity)
    eq(mapid(5), [0, 1, 2, 3, 4])
  })

  it('throws if second argument is not a valid array length', () => {
    assert.throws(() => {
      times(3)('cheers!')
    }, RangeError)
    assert.throws(() => {
      times(identity, -1)
    }, RangeError)
  })
})