Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastrange

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastrange

Create an array of numbers within a given range.

  • 1.5.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build status Coverage Status npm version GitHub CodeFactor

fastrange

A fast range function for JavaScript

Create an array of numbers within a given range. This is an useful alternative for the for loop when using a functional programming style where using map, filter and similar functions are preferred. Fastrange implements the range function known from Python. Fastrange is faster and more lightweight than alternative JavaScript implementations.

Installation

$ npm install fastrange

Usage

Using import, as a ESM module, for use with a bundler like webpack or rollup:

import range from 'fastrange';

As a commonjs module, for use in Node.js:

const range = require('fastrange');

Then:

range(10);
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

range(5, 10);
//=> [5, 6, 7, 8, 9]

range(4, 10, 2);
//=> [4, 6, 8]

API

range( [start=0], stop, [step=1] )

Returns an array of numbers dependent of the given parameters.

start

Type: number

Optional, start of the range, by default 0

stop

Type: number

End of the range, this value is not included in the result.

step

Type: number

Optional, step between the numbers in the range, by default 1

Performance

Many different implementations have been tested for perfomance and the fastest across browsers, using array push in a for loop, is being used in fastrange.

Tests

npm test

License

MIT © 2019 Edwin Martin

Keywords

FAQs

Package last updated on 18 Apr 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc