Skip to content

Commit 8620871

Browse files
committed
README
1 parent 296b3d6 commit 8620871

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
[![Coverage Status](https://coveralls.io/repos/github/smikitky/node-multi-integer-range/badge.svg?branch=dev)](https://coveralls.io/github/smikitky/node-multi-integer-range)
55
[![npm version](https://badge.fury.io/js/multi-integer-range.svg)](https://badge.fury.io/js/multi-integer-range)
66

7-
A small library which parses and manipulates comma-delimited integer ranges (such as "1-3,8-10").
8-
Such strings are typically used in print dialogs to indicate which pages to print.
7+
A small library which parses and manipulates comma-delimited integer ranges (such as "1-3,8-10"), which are typically used in print dialogs to indicate which pages to print.
98

10-
Supported operations include:
9+
Supported operations:
1110

1211
- Addition (e.g., `1-2,6` + `3-5` => `1-6`)
1312
- Subtraction (e.g., `1-10` - `5-9` => `1-4,10`)
@@ -16,19 +15,17 @@ Supported operations include:
1615
- Unbounded ranges (e.g., `5-` to mean "all integers >= 5") (optional)
1716
- Ranges including negative integers or zero
1817
- ES6 iterator (`for ... of`, spread operator)
19-
- Array creation (a.k.a. "flatten")
18+
- Array creation ("flatten")
2019

21-
Internal data are always *sorted and normalized* to the smallest possible
22-
representation.
20+
Internal data are always *sorted and normalized* to the smallest possible representation.
2321

2422
## Usage
2523

2624
### Install
2725

28-
Install via npm: `npm install multi-integer-range`
29-
30-
This library has no external dependencies, and can be used with Webpack and Browserify.
26+
Install via npm or yarn: `npm install multi-integer-range`
3127

28+
This library has no external dependencies, and can be used with module bundlers such as Webpack.
3229

3330
### Basic Example
3431

@@ -63,32 +60,26 @@ An initializer is one of the followings:
6360

6461
Pass it to the constructor to create a MultiRange object,
6562
or pass nothing to create an empty MultiRange object.
63+
A shorthand constructor function `multirange()` is also available,
64+
which you can use according to your preference.
6665

6766
```ts
6867
type Initializer =
6968
string | number | MultiRange | (number | [number, number])[];
7069
```
7170

7271
```js
72+
import MultiRange, { multirange } from 'multi-integer-range';
73+
7374
const mr1 = new MultiRange([7, 2, 9, 1, 8, 3]);
7475
const mr2 = new MultiRange('1-2, 3, 7-9');
7576
const mr3 = new MultiRange([[1,3], [7,9]]);
7677
const mr4 = new MultiRange(mr1); // clone
77-
```
78-
79-
A shorthand constructor function `multirange()` is also available.
80-
Use whichever you prefer.
81-
82-
```js
83-
import { multirange } from 'multi-integer-range';
84-
// OR
85-
// const { multirange } = require('multi-integer-range');
86-
8778
const mr5 = multirange('1,2,3,7,8,9');
8879
```
8980

90-
Internal data are always sorted and normalized,
91-
so the above five (`mr1`-`mr5`) hold a instance with identical range data.
81+
The above five (`mr1`-`mr5`) hold a instance with identical range data
82+
because internal data are always normalized.
9283

9384
The string parser is permissive and accepts space characters
9485
before/after comma/hyphens. Order is not important either, and
@@ -273,8 +264,7 @@ with a heavily fragmentated set of integers which are scarcely continuous
273264

274265
**Integer Type Checking**: Make sure you are not passing floating-point `number`s
275266
to this library. For example, don't do `new MultiRange(0.5);`.
276-
For performance reasons, the library does not strickly check if a passed number
277-
is an integer (it's a costly operation than you might think).
267+
For performance reasons, the library does not check if a passed number is an integer.
278268
Passing a float will result in unexpected and unrecoverable behavior.
279269

280270
## Development

0 commit comments

Comments
 (0)