You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-27Lines changed: 4 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ const len = mr.length(ranges1); // 10
79
79
80
80
## Creating a _normalized_ MultiIntegerRange
81
81
82
-
The fundamental data structure of this package is a **normalized** array of `[min, max]` tuples, as shown below. Here, "normalized" means the range data is in the smallest possible representation and is sorted in ascending order. You can denote an unbounded range using the JavaScript constant `Infinity`.
82
+
The fundamental data structure of this package is a **normalized** array of `[min, max]` tuples, as shown below. Here, "normalized" means the range data is in the smallest possible representation and is sorted in ascending order. You can denote an unbounded (aka infinite) range using the JavaScript constant `Infinity`.
83
83
84
84
<!-- prettier-ignore -->
85
85
```ts
@@ -144,30 +144,7 @@ console.log(
144
144
145
145
## API Reference
146
146
147
-
All functions are _pure_; they do not change the input data nor do they have any side effects. All functions are exported as named exports. All `MultiIntegerRange`s returned by these functions are normalized. `MIR` is just a short alias for `MultiIntegerRange` (also available in d.ts).
148
-
149
-
-`parse(data: string, options?: Options): MIR` Parses the given string. See below for the options.
150
-
-`normalize(data?:(number | Range)[] | number): MIR` Normalizes the given number or the array of numbers/Ranges.
151
-
-`initialize(data?: (number | Range)[] | number | string, options?: Options)`: Conditionally calls either `parse` or `normalize` and returns a new MultiIntegerRange. This takes an "Initializer" in version ≤ 4.
152
-
-`append(a: MIR, b: MIR): MIR` Appends the two values.
153
-
-`subtract(a: MIR, b: MIR): MIR` Subtracts `b` from `a`.
154
-
-`intersect(a: MIR, b: MIR): MIR` Calculates the interesction, i.e., integers that belong to both `a` and `b`.
155
-
-`has(a: MIR, b: MIR): boolean` Checks if `b` is equal to or a subset of `a`.
156
-
-`length(data: MIR): number` Calculates how many numbers are effectively included in the given data (i.e., 5 for '3,5-7,9'). Returns Inifnity for unbounded ranges.
157
-
-`equals(a: MIR, b: MIR): boolean` Checks if `a` and `b` contains the same range data. (If you like, you can use other deep-equal utilities instead.)
158
-
-`isUnbounded(data: MIR): boolean` Returns true if the instance is unbounded.
159
-
-`min(data: MIR): number | undefined` Returns the minimum integer. May return -Infinity.
160
-
-`max(data: MIR): number | undefined` Returns the maxinum integer. May return Infinity.
161
-
-`tail(data: MIR): MIR` Removes the minimum integer.
162
-
-`init(data: MIR): MIR` Removes the maxinum integer.
163
-
-`stringify(data: MIR): string` Returns the string respresentation of the given data (the opposite of parse()).
164
-
-`flatten(data: MIR): number[]` Builds a flat array of integers. This may be slow and memory-consuming for large ranges such as '1-10000'.
165
-
-`iterate(data: MIR): Iterable<number>` Returns an ES6 iterable object. See the description below.
166
-
167
-
Available `options` that can be passed to `parse()`:
0 commit comments