Package Exports
- parse-numeric-range
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-numeric-range) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-parse-numeric-range
Parses expressions like 1-10,20-30. Returns an energetic array.
Supported Expressions
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,-2 | [-1,0,1,2,-2] |
-1...3,-2 | [-1,0,1,2,-2] |
What's this useful for? Well, letting users input these sorts of things and then making them programmatically useful.
Usage
First, npm install parse-numeric-range
.
var rangeParser = require('parse-numeric-range');
var nums = rangeParser.parse('4,6,8-10,12,14..16,18,20...23');
console.log("The first " + nums.length + " composite numbers are: " + nums.join(', '));