Skip to content

Commit 203dfed

Browse files
committed
Documentation
1 parent 001c1c1 commit 203dfed

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ console.log(pages.segmentLength()); // 2
5454
Some methods and the constructor take one *Initializer* parameter.
5555
An initializer is one of the followings:
5656

57-
- a valid string (eg `'1-3,5'`)
58-
- an array of integers (eg `[1, 2, 3, 5]`)
59-
- an array of `[number, number]` tuples (eg `[[1, 3], [5, 5]]`)
60-
- mixture of integers and tuples (eg `[[1, 3], 5]`)
61-
- a single integer (eg `1`)
57+
- a valid string (e.g., `'1-3,5'`)
58+
- an array of integers (e.g., `[1, 2, 3, 5]`)
59+
- an array of `[min, max]` tuples (e.g., `[[1, 3], [5, 5]]`)
60+
- mixture of integers and tuples (e.g., `[[1, 3], 5]`)
61+
- a single integer (e.g., `1`)
6262
- another MultiRange instance
6363

6464
Pass it to the constructor to create a MultiRange object,
@@ -126,12 +126,12 @@ To get a copy of the instance, use `clone()`, or alternatively the copy construc
126126
- `toString(): string` Returns the string respresentation of this MultiRange.
127127
- `getRanges(): [number, number][]` Exports the whole range data as an array of [number, number] tuples.
128128
- `toArray(): number[]` Builds an array of integer which holds all integers in this MultiRange. This may be slow and memory-consuming for large ranges such as '1-10000'.
129-
- `getIterator(): Object` Returns ES6-compatible iterator. See the description below.
129+
- `getIterator(): Object` Returns an ES6-compatible iterator. See the description below.
130130

131131
Available `options` that can be passed to the constructor:
132132

133-
- `parseNegative` (boolean, default = false): Enables parsing negative ranges (eg `(-10)-(-3)`).
134-
- `parseUnbounded` (boolean, default = false): Enables parsing unbounded ranges (eg `-5,10-`).
133+
- `parseNegative` (boolean, default = false): Enables parsing negative ranges (e.g., `(-10)-(-3)`).
134+
- `parseUnbounded` (boolean, default = false): Enables parsing unbounded ranges (e.g., `-5,10-`).
135135

136136

137137
### Unbounded Ranges (optional)
@@ -177,8 +177,8 @@ const pagesToPrint = unbounded(userInput).intersect(pagesInMyDoc);
177177
console.log(pagesToPrint.toString()); // prints '1-10,15-20,90-100'
178178
```
179179

180-
Unbounded ranges cannot be iterated over, and you cannot call `#toArray()` for obvious reasons.
181-
Calling `#length()` for unbounded ranges will return `Infinity`.
180+
Unbounded ranges cannot be iterated over, and you cannot call `toArray()` for obvious reasons.
181+
Calling `length()` for unbounded ranges will return `Infinity`.
182182

183183

184184
### Ranges Containing Zero and Negative Integers
@@ -237,13 +237,12 @@ while (!(page = it.next()).done) {
237237

238238
## TypeScript Definition File
239239

240-
This library comes with a TypeScript definition file. Starting from TypeScript 1.6,
241-
The TypeScript compiler can find this definition file automatically.
240+
This library comes with a TypeScript definition file.
241+
Starting from TS 1.6, the compiler can find this definition file automatically.
242242

243243
The definition file only contains declarations that are compatible with ES5.
244-
If your TypeScript project needs support for iterators,
245-
add the following snippet somewhere in your project (eg "typings" directory)
246-
to avoid compile-time errors.
244+
If your TypeScript project needs support for iterators (e.g., `for ... of` or `[...multirange('1-5')]`),
245+
add the following snippet somewhere in your project to avoid compile-time errors.
247246

248247
```ts
249248
declare module "multi-integer-range" {
@@ -253,9 +252,10 @@ declare module "multi-integer-range" {
253252
}
254253
```
255254

256-
Note that downlevel iteration for `--target=es5` needs a polyfill for symbols and
257-
`--downlevelIteration` compile flag, available since TypeScript 2.3.
258-
If these bothers you, you can always manually use `getIterator` as described above.
255+
In addition, if your project is `--target es5`, you'll need a polyfill for symbols,
256+
`--downlevelIteration` compile option (available since TS 2.3),
257+
plus `--lib es2015.iterable` compile option.
258+
If these bother you, you can always manually use `getIterator()` as described above.
259259

260260

261261
## Changelog

0 commit comments

Comments
 (0)