parse-numeric-range

WebJar for parse-numeric-range

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

parse-numeric-range
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

parse-numeric-range
WebJar for parse-numeric-range
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/euank/node-parse-numeric-range

Download parse-numeric-range

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/parse-numeric-range/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>parse-numeric-range</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/parse-numeric-range/
implementation 'org.webjars.npm:parse-numeric-range:0.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/parse-numeric-range/
implementation ("org.webjars.npm:parse-numeric-range:0.0.2")
'org.webjars.npm:parse-numeric-range:jar:0.0.2'
<dependency org="org.webjars.npm" name="parse-numeric-range" rev="0.0.2">
  <artifact name="parse-numeric-range" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='parse-numeric-range', version='0.0.2')
)
libraryDependencies += "org.webjars.npm" % "parse-numeric-range" % "0.0.2"
[org.webjars.npm/parse-numeric-range "0.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

node-parse-numeric-range

Parses expressions like 1-10,20-30. Returns an energetic (as opposed to lazy) 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 [-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.

Usage

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(", ")}`,
);

ES6

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(", ")}`,
);

Versions

Version
0.0.2