@nkp/range
Zero dependency utility to create iterable discrete and continuous ranges.
import { range } from '@nkp/range';
for (const state of range({ start: 0, end: 6, step: 2, inclusive: true })) {
const { cursor, step, to, set, isInBounds, } = state;
console.log(cursor);
}
// 0
// 2
// 4
// 6
Table of contents
Exports
@nkp/range
exports both CommonJS and ES modules.
Installation
npm
npm install @nkp/range
yarn
yarn add @nkp/range
pnpm
pnpm add @nkp/range
Usage
import { range } from '@nkp/range';
for (const state of range({ start: 0, end: 6, step: 2, inclusive: true })) {
const { cursor, step, to, set, isInBounds, } = state;
console.log(cursor);
}
// 0
// 2
// 4
// 6
Publishing
To a release a new version:
- Update the version number in package.json
- Push the new version to the
master
branch on GitHub - Create a
new release
on GitHub for the latest version
This will trigger a GitHub action that tests and publishes the npm package.