New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rangestar

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangestar

Another range array generator. Written in TypeScript, well tested, no floating-point BS, super fast and tiny.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Range*

Build Status Coverage npm bundle size npm version

Another range array generator. Written in TypeScript, well tested, no floating-point BS, super fast and tiny.

Installation

yarn add rangestar

Examples

Supports generators...

const range = require('rangestar');

for (const r of range.rangeGenerator(3)) {
	console.log(r);
}

// 0
// 1
// 2

for (const r of range.rangeGenerator(1, 3)) {
	console.log(r);
}

// 1
// 2

...and arrays...

const a = range.rangeArray(3);
console.log(a);

// [0, 1, 2]

const b = rangeArray(3, 3.4, 0.1);
console.log(b);

// [3, 3.1, 3.2, 3.3]

...and humans:

const lodashRange = require('lodash.range');
const c = lodashRange(3, 3.4, 0.1);
console.log(c);

// [3, 3.1, 3.2, 3.3000000000000003]
// WHAT THE F$#%?

API

The START value will be included in the result, while STOP will not.

Range generator

// From 0 to STOP:
range.rangeGenerator(STOP: number): Generator<number>

// From START to STOP with optional STEP:
range.rangeGenerator(START: number, STOP: number, STEP?: number): Generator<number>

Range array

Same concept.

// From 0 to STOP:
range.rangeGenerator(STOP: number): number[]

// From START to STOP with optional STEP:
range.rangeGenerator(START: number, STOP: number, STEP?: number): number[]

Benchmarks

Use yarn benchmark to run the benchmarks. Python and Bash are required.

LibraryResults
Range*14.424ms
Lodash13.017ms
range19.874ms
Python range20.853ms

Credits

This library is based on Lodash's range function.

Keywords

range

FAQs

Package last updated on 22 Jan 2020

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