
Product
Introducing Reachability for PHP
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.
parse-numeric-range
Advanced tools
Takes a string, such as "1,2,3-10,5-8" and turns it into an array of numbers
Parses expressions like 1-10,20-30. Returns an energetic (as opposed to lazy) array.
Comprehensive supported expression examples:
| Expression | result |
|---|---|
| [] | |
| 1 | [1] |
| 1,2 | [1,2] |
| -10 | [-10] |
| -3,-3 | [-3, -3] |
| -1-2,-2 | [-1,0,1,2,-2] |
| -1--2 | [-1,-2] |
| -1..2,-2 | [-1,0,1,2,-2] |
| -1...3,-2 | [-1,0,1,2,-2] |
| 1⋯3 | [1,2] |
| 1…3 | [1,2] |
| 1‥3 | [1,2,3] |
What's this useful for? Well, letting users input these sorts of things and then making them programmatically useful.
First, npm install parse-numeric-range.
const rangeParser = require("parse-numeric-range");
const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");
console.log(
`The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);
import rangeParser from "parse-numeric-range";
const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");
console.log(
`The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);
The range-parser package is used to parse HTTP Range headers, which specify a range of bytes to be sent from a server. While it is more specialized for HTTP use cases, it can also handle numeric ranges but is not as general-purpose as parse-numeric-range.
FAQs
Takes a string, such as "1,2,3-10,5-8" and turns it into an array of numbers
We found that parse-numeric-range demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.