🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

partition-interval

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

partition-interval

Partitions an interval as evenly as possible.

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

partition-interval

version CI gzip size brotli size Sponsor
Partitions an interval as evenly as possible.

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.

License

MIT © Tomer Aberbach
Apache 2.0 © Google

Keywords

partition

FAQs

Package last updated on 01 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts