@sullux/fp-light-range

0.0.1 • Public • Published

home

fp-light-range

npm i @sullux/fp-light-range source test

Creates an iterable of integers spanning the given range. This can be a good way to functionally implement next n items logic or repeat n times logic.

range

range(start: Number, end: Number): Iterable<Number>

Given a start less than end, iterates forward; otherwise, iterates backwards. All ranges are inclusive. The following tests illustrate the functionality.

const { range } = require('./range')
const { deepStrictEqual } = require('assert')

describe('range', () => {
  it('should produce a low to high range', () => deepStrictEqual(
    [...range(1, 3)],
    [1, 2, 3]
  ))
  it('should produce a high to low range', () => deepStrictEqual(
    [...range(3, 1)],
    [3, 2, 1]
  ))
  it('should produce a single digit range', () => deepStrictEqual(
    [...range(1, 1)],
    [1]
  ))
})

...

Readme

Keywords

Package Sidebar

Install

npm i @sullux/fp-light-range

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

1.89 kB

Total Files

3

Last publish

Collaborators

  • sullux