
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
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
The npm package parse-numeric-range receives a total of 1,186,694 weekly downloads. As such, parse-numeric-range popularity was classified as popular.
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.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.