@nkp/range
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@nkp/range

npm version deploy status known vulnerabilities

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:

  1. Update the version number in package.json
  2. Push the new version to the master branch on GitHub
  3. Create a new release on GitHub for the latest version

This will trigger a GitHub action that tests and publishes the npm package.

Readme

Keywords

Package Sidebar

Install

npm i @nkp/range

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

15.8 kB

Total Files

6

Last publish

Collaborators

  • nickkelly