🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

parse-numeric-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

parse-numeric-range

Takes a string, such as "1,2,3-10,5-8" and turns it into an array of numbers

1.3.0
latest
Source
npm
Version published
Weekly downloads
1.1M
-11.88%
Maintainers
1
Weekly downloads
 
Created

What is parse-numeric-range?

The parse-numeric-range npm package is a utility for parsing numeric ranges from strings. It can handle individual numbers, ranges, and combinations of both, making it useful for scenarios where you need to interpret and work with numeric ranges from user input or configuration files.

What are parse-numeric-range's main functionalities?

Parse Single Numbers

This feature allows you to parse a single number from a string and returns it as an array containing that number.

const parse = require('parse-numeric-range');
const result = parse('5');
console.log(result); // [5]

Parse Ranges

This feature allows you to parse a range of numbers from a string and returns an array containing all the numbers in that range.

const parse = require('parse-numeric-range');
const result = parse('1-5');
console.log(result); // [1, 2, 3, 4, 5]

Parse Combinations of Numbers and Ranges

This feature allows you to parse a combination of individual numbers and ranges from a string, returning an array containing all the specified numbers.

const parse = require('parse-numeric-range');
const result = parse('1-3,5,7-9');
console.log(result); // [1, 2, 3, 5, 7, 8, 9]

Other packages similar to parse-numeric-range

Keywords

parse

FAQs

Package last updated on 22 Aug 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