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

@bramus/range

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bramus/range

Create an array containing a range of elements (cfr. PHP's range)

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
increased by35.29%
Maintainers
1
Weekly downloads
 
Created
Source

Range

Create an array containing a range of elements (cfr. PHP's range)

Installation

npm i @bramus/range

Usage / Example

import { range } from '@bramus/range';

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

const r2 = range(7, 12);
// ~> [7, 8, 9, 10, 11, 12]

const r3 = range(0, 100, 10);
// ~> [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

🔗 Try it out online in the playground: https://codepen.io/bramus/pen/dyVMPxV

API

The exposed function has an API identical to PHP's range method:

range(start, end, step = 1);

Parameters:

  • start: First value of the sequence.
  • end: The sequence is ended upon reaching the end value.
  • step (default: 1): If a step value is given, it will be used as the increment between elements in the sequence. step should be given as a positive number. If not specified, step will default to 1.

Limitations

Unlike PHP's range, this function is limited to numbers only. In case you do want to get letters, combine range() with Array.map().

License

@bramus/range is released under the MIT public license. See the enclosed LICENSE for details.

Keywords

FAQs

Package last updated on 17 Dec 2021

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