1.0.1 • Published 7 days ago

partition-interval v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 days ago

Features

  • Lazy: returns an Iterable for the common case of not needing everything in memory at once
  • Small: just ~260 B minzipped
  • Robust: property-based testing with fast-check

Install

$ npm i partition-interval

Usage

import partitionInterval from 'partition-interval'

// Lazily iterate over the returned iterable.
for (const interval of partitionInterval([0, 99], 4)) {
  console.log(interval)
}
//=> [ 0, 24 ]
//=> [ 25, 49 ]
//=> [ 50, 74 ]
//=> [ 75, 99 ]

// Collect the returned iterable into an array.
const intervals = [...partitionInterval([-31, 89], 5)]
console.log(intervals)
//=> [ [-31, -8], [-7, 16], [17, 40], [41, 64], [65, 89] ]

Contributing

Stars are always welcome!

For bugs and feature requests, please create an issue.

For pull requests, please read the contributing guidelines.

License

Apache License 2.0

This is not an official Google product.

1.0.1

7 days ago

1.0.0

2 months ago