itertools 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  [![npm](https://img.shields.io/npm/v/itertools.svg)](https://www.npmjs.com/package/itertools)
2
2
  [![Build Status](https://github.com/nvie/itertools.js/workflows/test/badge.svg)](https://github.com/nvie/itertools.js/actions)
3
- [![Minified Size](https://badgen.net/bundlephobia/minzip/itertools)](https://bundlephobia.com/result?p=itertools)
4
3
 
5
4
  A JavaScript port of Python's awesome
6
5
  [itertools](https://docs.python.org/library/itertools.html) standard library.
@@ -21,13 +20,12 @@ Usage example:
21
20
  4 'there'
22
21
  ```
23
22
 
24
-
25
23
  ## About argument order
26
24
 
27
- In Python, many of the itertools take a function as an argument. In the JS
25
+ In Python, many of the itertools take a function as an argument. In the JS
28
26
  port of these we initially kept these orderings the same to stick closely to
29
27
  the Python functions, but in practice, it turns out to be more pragmatic to
30
- flip them, so the function gets to be the second param. Example:
28
+ flip them, so the function gets to be the second param. Example:
31
29
 
32
30
  In Python:
33
31
 
@@ -49,14 +47,12 @@ remaing aesthetically pleasing:
49
47
  import { map } from 'itertools';
50
48
 
51
49
  const numbers = [1, 2, 3];
52
- const squares = map(numbers, n => {
53
-
50
+ const squares = map(numbers, (n) => {
54
51
  //
55
52
  // Do something wild with these numbers here
56
53
  //
57
54
  // ...
58
55
  return n * n;
59
-
60
56
  });
61
57
  ```
62
58
 
@@ -64,76 +60,73 @@ const squares = map(numbers, n => {
64
60
 
65
61
  The `itertools` package consists of a few building blocks:
66
62
 
67
- * [Ports of builtins](#ports-of-builtins)
68
- * [Ports of itertools](#ports-of-itertools)
69
- * [Ports of more-itertools](#ports-of-more-itertools)
70
- * [Additions](#additions)
71
-
63
+ - [Ports of builtins](#ports-of-builtins)
64
+ - [Ports of itertools](#ports-of-itertools)
65
+ - [Ports of more-itertools](#ports-of-more-itertools)
66
+ - [Additions](#additions)
72
67
 
73
68
  ### Ports of builtins
74
69
 
75
- * [every](#every)
76
- * [some](#some)
77
- * [contains](#contains)
78
- * [enumerate](#enumerate)
79
- * [filter](#filter)
80
- * [iter](#iter)
81
- * [map](#map)
82
- * [max](#max)
83
- * [min](#min)
84
- * [range](#range)
85
- * [reduce](#reduce)
86
- * [sorted](#sorted)
87
- * [sum](#sum)
88
- * [zip](#zip)
89
- * [zip3](#zip3)
90
-
91
- <a name="every" href="#every">#</a> <b>every</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
92
-
93
- Returns true when every of the items in iterable are truthy. An optional key
70
+ - [every](#every)
71
+ - [some](#some)
72
+ - [contains](#contains)
73
+ - [enumerate](#enumerate)
74
+ - [filter](#filter)
75
+ - [iter](#iter)
76
+ - [map](#map)
77
+ - [max](#max)
78
+ - [min](#min)
79
+ - [range](#range)
80
+ - [reduce](#reduce)
81
+ - [sorted](#sorted)
82
+ - [sum](#sum)
83
+ - [zip](#zip)
84
+ - [zip3](#zip3)
85
+
86
+ <a name="every" href="#every">#</a> <b>every</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
87
+
88
+ Returns true when every of the items in iterable are truthy. An optional key
94
89
  function can be used to define what truthiness means for this specific
95
90
  collection.
96
91
 
97
92
  Examples:
98
93
 
99
94
  ```ts
100
- every([]) // => true
101
- every([0]) // => false
102
- every([0, 1, 2]) // => false
103
- every([1, 2, 3]) // => true
95
+ every([]); // => true
96
+ every([0]); // => false
97
+ every([0, 1, 2]); // => false
98
+ every([1, 2, 3]); // => true
104
99
  ```
105
100
 
106
101
  Examples with using a key function:
107
102
 
108
103
  ```ts
109
- every([2, 4, 6], n => n % 2 === 0) // => true
110
- every([2, 4, 5], n => n % 2 === 0) // => false
104
+ every([2, 4, 6], (n) => n % 2 === 0); // => true
105
+ every([2, 4, 5], (n) => n % 2 === 0); // => false
111
106
  ```
112
107
 
108
+ <a name="some" href="#some">#</a> <b>some</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
113
109
 
114
- <a name="some" href="#some">#</a> <b>some</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
115
-
116
- Returns true when some of the items in iterable are truthy. An optional key
110
+ Returns true when some of the items in iterable are truthy. An optional key
117
111
  function can be used to define what truthiness means for this specific
118
112
  collection.
119
113
 
120
114
  Examples:
121
115
 
122
116
  ```ts
123
- some([]) // => false
124
- some([0]) // => false
125
- some([0, 1, null, undefined]) // => true
117
+ some([]); // => false
118
+ some([0]); // => false
119
+ some([0, 1, null, undefined]); // => true
126
120
  ```
127
121
 
128
122
  Examples with using a key function:
129
123
 
130
124
  ```ts
131
- some([1, 4, 5], n => n % 2 === 0) // => true
132
- some([{name: 'Bob'}, {name: 'Alice'}], person => person.name.startsWith('C')) // => false
125
+ some([1, 4, 5], (n) => n % 2 === 0); // => true
126
+ some([{ name: 'Bob' }, { name: 'Alice' }], (person) => person.name.startsWith('C')); // => false
133
127
  ```
134
128
 
135
-
136
- <a name="contains" href="#contains">#</a> <b>contains</b>(haystack: <i>Iterable&lt;T&gt;</i>, needle: <i>T</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
129
+ <a name="contains" href="#contains">#</a> <b>contains</b>(haystack: <i>Iterable&lt;T&gt;</i>, needle: <i>T</i>): <i>boolean</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
137
130
 
138
131
  Returns true when some of the items in the iterable are equal to the target
139
132
  object.
@@ -141,17 +134,16 @@ object.
141
134
  Examples:
142
135
 
143
136
  ```ts
144
- contains([], 'whatever') // => false
145
- contains([3], 42) // => false
146
- contains([3], 3) // => true
147
- contains([0, 1, 2], 2) // => true
137
+ contains([], 'whatever'); // => false
138
+ contains([3], 42); // => false
139
+ contains([3], 3); // => true
140
+ contains([0, 1, 2], 2); // => true
148
141
  ```
149
142
 
143
+ <a name="enumerate" href="#enumerate">#</a> <b>enumerate</b>(iterable: <i>Iterable&lt;T&gt;</i>, start: <i>number = 0</i>): <i>Iterable&lt;[number, T]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
150
144
 
151
- <a name="enumerate" href="#enumerate">#</a> <b>enumerate</b>(iterable: <i>Iterable&lt;T&gt;</i>, start: <i>number = 0</i>): <i>Iterable&lt;[number, T]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
152
-
153
- Returns an iterable of enumeration pairs. Iterable must be a sequence, an
154
- iterator, or some other object which supports iteration. The elements produced
145
+ Returns an iterable of enumeration pairs. Iterable must be a sequence, an
146
+ iterator, or some other object which supports iteration. The elements produced
155
147
  by returns a tuple containing a counter value (starting from 0 by default) and
156
148
  the values obtained from iterating over given iterable.
157
149
 
@@ -164,28 +156,25 @@ console.log([...enumerate(['hello', 'world'])]);
164
156
  // [0, 'hello'], [1, 'world']]
165
157
  ```
166
158
 
167
- <a name="filter" href="#filter">#</a> <b>filter</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>Array&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
159
+ <a name="filter" href="#filter">#</a> <b>filter</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>T[]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
168
160
 
169
- Non-lazy version of [ifilter](#ifilter).
161
+ Eager version of [ifilter](#ifilter).
170
162
 
163
+ <a name="iter" href="#iter">#</a> <b>iter</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterator&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
171
164
 
172
- <a name="iter" href="#iter">#</a> <b>iter</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterator&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
173
-
174
- Returns an iterator object for the given iterable. This can be used to
175
- manually get an iterator for any iterable datastructure. The purpose and main
165
+ Returns an iterator object for the given iterable. This can be used to
166
+ manually get an iterator for any iterable datastructure. The purpose and main
176
167
  use case of this function is to get a single iterator (a thing with state,
177
168
  think of it as a "cursor") which can only be consumed once.
178
169
 
170
+ <a name="map" href="#map">#</a> <b>map</b>(iterable: _Iterable&lt;T&gt;_, mapper: _(item: T) =&gt; V_): _V[]_ [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
179
171
 
180
- <a name="map" href="#map">#</a> <b>map</b>(iterable: _Iterable&lt;T&gt;_, mapper: _T =&gt; V_): _Array&lt;V&gt;_ [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
181
-
182
- Non-lazy version of [imap](#imap).
183
-
172
+ Eager version of [imap](#imap).
184
173
 
185
- <a name="max" href="#max">#</a> <b>max</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>T =&gt; number</i>): <i>Maybe&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
174
+ <a name="max" href="#max">#</a> <b>max</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>(item: T) =&gt; number</i>): <i>T | undefined</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
186
175
 
187
- Return the largest item in an iterable. Only works for numbers, as ordering is
188
- pretty poorly defined on any other data type in JS. The optional `keyFn`
176
+ Return the largest item in an iterable. Only works for numbers, as ordering is
177
+ pretty poorly defined on any other data type in JS. The optional `keyFn`
189
178
  argument specifies a one-argument ordering function like that used for
190
179
  [sorted](#sorted).
191
180
 
@@ -194,11 +183,10 @@ If the iterable is empty, `undefined` is returned.
194
183
  If multiple items are maximal, the function returns either one of them, but
195
184
  which one is not defined.
196
185
 
186
+ <a name="min" href="#min">#</a> <b>min</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>(item: T) =&gt; number</i>): <i>T | undefined</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
197
187
 
198
- <a name="min" href="#min">#</a> <b>min</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>T =&gt; number</i>): <i>Maybe&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
199
-
200
- Return the smallest item in an iterable. Only works for numbers, as ordering
201
- is pretty poorly defined on any other data type in JS. The optional `keyFn`
188
+ Return the smallest item in an iterable. Only works for numbers, as ordering
189
+ is pretty poorly defined on any other data type in JS. The optional `keyFn`
202
190
  argument specifies a one-argument ordering function like that used for
203
191
  [sorted](#sorted).
204
192
 
@@ -207,9 +195,8 @@ If the iterable is empty, `undefined` is returned.
207
195
  If multiple items are minimal, the function returns either one of them, but
208
196
  which one is not defined.
209
197
 
210
-
211
- <a name="range" href="#range">#</a> <b>range</b>(stop: <i>number</i>): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")<br />
212
- <a name="range" href="#range">#</a> <b>range</b>(start: <i>number</i>, stop: <i>number</i>, step: <i>number</i> = 1): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
198
+ <a name="range" href="#range">#</a> <b>range</b>(stop: <i>number</i>): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')<br />
199
+ <a name="range" href="#range">#</a> <b>range</b>(start: <i>number</i>, stop: <i>number</i>, step: <i>number</i> = 1): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
213
200
 
214
201
  Returns an iterator producing all the numbers in the given range one by one,
215
202
  starting from `start` (default 0), as long as `i < stop`, in increments of
@@ -234,19 +221,14 @@ the stop condition `n > stop` is satisfied.
234
221
  The produced range will be empty if the first value to produce already does not
235
222
  meet the value constraint.
236
223
 
237
-
238
- <a name="reduce" href="#reduce">#</a> <b>reduce</b>(iterable: <i>Iterable&lt;T&gt;</i>, reducer: <i>(O, T, number) =&gt; O</i>, start: <i>O</i>): <i>O</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")<br />
239
- <a name="reduce" href="#reduce">#</a> <b>reduce</b>(iterable: <i>Iterable&lt;T&gt;</i>, reducer: <i>(T, T, number) =&gt; T</i>): <i>Maybe&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
224
+ <a name="reduce" href="#reduce">#</a> <b>reduce</b>(iterable: <i>Iterable&lt;T&gt;</i>, reducer: <i>(O, T, number) =&gt; O</i>, start: <i>O</i>): <i>O</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')<br />
225
+ <a name="reduce" href="#reduce">#</a> <b>reduce</b>(iterable: <i>Iterable&lt;T&gt;</i>, reducer: <i>(T, T, number) =&gt; T</i>): <i>T | undefined</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
240
226
 
241
227
  Apply function of two arguments cumulatively to the items of sequence, from
242
- left to right, so as to reduce the sequence to a single value. For example:
228
+ left to right, so as to reduce the sequence to a single value. For example:
243
229
 
244
230
  ```ts
245
- reduce(
246
- [1, 2, 3, 4, 5],
247
- (total, x) => total + x,
248
- 0
249
- )
231
+ reduce([1, 2, 3, 4, 5], (total, x) => total + x, 0);
250
232
  ```
251
233
 
252
234
  calculates
@@ -259,99 +241,87 @@ The left argument, `total`, is the accumulated value and the right argument,
259
241
  Without an explicit initializer arg:
260
242
 
261
243
  ```ts
262
- reduce(
263
- [1, 2, 3, 4, 5],
264
- (total, x) => total + x
265
- )
244
+ reduce([1, 2, 3, 4, 5], (total, x) => total + x);
266
245
  ```
267
246
 
268
247
  it calculates
269
248
 
270
249
  ((((1+2)+3)+4)+5)
271
250
 
272
-
273
-
274
- <a name="sorted" href="#sorted">#</a> <b>sorted</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>T =&gt; Primitive</i></i>, reverse?: <i>boolean</i>): <i>Array&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
251
+ <a name="sorted" href="#sorted">#</a> <b>sorted</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>(item: T) =&gt; Primitive</i></i>, reverse?: <i>boolean</i>): <i>T[]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
275
252
 
276
253
  Return a new sorted list from the items in iterable.
277
254
 
278
255
  Has two optional arguments:
279
256
 
280
- * `keyFn` specifies a function of one argument providing a primitive identity
281
- for each element in the iterable. that will be used to compare. The default
282
- value is to use a default identity function that is only defined for
283
- primitive types.
257
+ - `keyFn` specifies a function of one argument providing a primitive identity
258
+ for each element in the iterable. that will be used to compare. The default
259
+ value is to use a default identity function that is only defined for
260
+ primitive types.
284
261
 
285
- * `reverse` is a boolean value. If `true`, then the list elements are sorted
286
- as if each comparison were reversed.
262
+ - `reverse` is a boolean value. If `true`, then the list elements are sorted
263
+ as if each comparison were reversed.
287
264
 
265
+ <a name="sum" href="#sum">#</a> <b>sum</b>(iterable: <i>Iterable&lt;number&gt;</i>): <i>number</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
288
266
 
289
- <a name="sum" href="#sum">#</a> <b>sum</b>(iterable: <i>Iterable&lt;number&gt;</i>): <i>number</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
290
-
291
- Sums the items of an iterable from left to right and returns the total. The
267
+ Sums the items of an iterable from left to right and returns the total. The
292
268
  sum will defaults to 0 if the iterable is empty.
293
269
 
270
+ <a name="zip" href="#zip">#</a> <b>zip</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>): <i>[T1, T2][]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')<br />
271
+ <a name="zip3" href="#zip3">#</a> <b>zip3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>): <i>[T1, T2, T3][]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js 'Source')
294
272
 
295
- <a name="zip" href="#zip">#</a> <b>zip</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>): <i>Array&lt;[T1, T2]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")<br />
296
- <a name="zip3" href="#zip3">#</a> <b>zip3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>): <i>Array&lt;[T1, T2, T3]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/builtins.js "Source")
297
-
298
- Non-lazy version of [izip](#izip) / [izip3](#izip3).
299
-
273
+ Eager version of [izip](#izip) / [izip3](#izip3).
300
274
 
301
275
  ### Ports of itertools
302
276
 
303
- * [chain](#chain)
304
- * [compress](#compress)
305
- * [count](#count)
306
- * [cycle](#cycle)
307
- * [dropwhile](#dropwhile)
308
- * [groupby](#groupby)
309
- * [icompress](#icompress)
310
- * [ifilter](#ifilter)
311
- * [imap](#imap)
312
- * [islice](#islice)
313
- * [izip](#izip)
314
- * [izip3](#izip3)
315
- * [izipLongest](#izipLongest)
316
- * [izipMany](#izipMany)
317
- * [permutations](#permutations)
318
- * [repeat](#repeat)
319
- * [takewhile](#takewhile)
320
- * [zipLongest](#zipLongest)
321
- * [zipMany](#zipMany)
322
-
323
- <a name="chain" href="#chain">#</a> <b>chain</b>(...iterables: <i>Array&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
277
+ - [chain](#chain)
278
+ - [compress](#compress)
279
+ - [count](#count)
280
+ - [cycle](#cycle)
281
+ - [dropwhile](#dropwhile)
282
+ - [groupby](#groupby)
283
+ - [icompress](#icompress)
284
+ - [ifilter](#ifilter)
285
+ - [imap](#imap)
286
+ - [islice](#islice)
287
+ - [izip](#izip)
288
+ - [izip3](#izip3)
289
+ - [izipLongest](#izipLongest)
290
+ - [izipMany](#izipMany)
291
+ - [permutations](#permutations)
292
+ - [repeat](#repeat)
293
+ - [takewhile](#takewhile)
294
+ - [zipLongest](#zipLongest)
295
+ - [zipMany](#zipMany)
296
+
297
+ <a name="chain" href="#chain">#</a> <b>chain</b>(...iterables: <i>Iterable&lt;T&gt;[]</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
324
298
 
325
299
  Returns an iterator that returns elements from the first iterable until it is
326
300
  exhausted, then proceeds to the next iterable, until all of the iterables are
327
- exhausted. Used for treating consecutive sequences as a single sequence.
328
-
329
-
330
- <a name="compress" href="#compress">#</a> <b>compress</b>(iterable: <i>Iterable&lt;T&gt;</i>, selectors: <i>Iterable&lt;boolean&gt;</i>): <i>Array&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
301
+ exhausted. Used for treating consecutive sequences as a single sequence.
331
302
 
332
- Non-lazy version of [icompress](#icompress).
303
+ <a name="compress" href="#compress">#</a> <b>compress</b>(iterable: <i>Iterable&lt;T&gt;</i>, selectors: <i>Iterable&lt;boolean&gt;</i>): <i>T[]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
333
304
 
305
+ Eager version of [icompress](#icompress).
334
306
 
335
- <a name="count" href="#count">#</a> <b>count</b>(start: <i>number</i>, step: <i>number</i>): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
307
+ <a name="count" href="#count">#</a> <b>count</b>(start: <i>number</i>, step: <i>number</i>): <i>Iterable&lt;number&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
336
308
 
337
309
  Returns an iterator that counts up values starting with number `start` (default
338
- 0), incrementing by `step`. To decrement, use a negative step number.
310
+ 0), incrementing by `step`. To decrement, use a negative step number.
339
311
 
340
-
341
- <a name="cycle" href="#cycle">#</a> <b>cycle</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
312
+ <a name="cycle" href="#cycle">#</a> <b>cycle</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
342
313
 
343
314
  Returns an iterator producing elements from the iterable and saving a copy of
344
- each. When the iterable is exhausted, return elements from the saved copy.
315
+ each. When the iterable is exhausted, return elements from the saved copy.
345
316
  Repeats indefinitely.
346
317
 
347
-
348
- <a name="dropwhile" href="#dropwhile">#</a> <b>dropwhile</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>T =&gt; bool</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
318
+ <a name="dropwhile" href="#dropwhile">#</a> <b>dropwhile</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>(item: T) =&gt; boolean</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
349
319
 
350
320
  Returns an iterator that drops elements from the iterable as long as the
351
- predicate is true; afterwards, returns every remaining element. **Note:** the
321
+ predicate is true; afterwards, returns every remaining element. **Note:** the
352
322
  iterator does not produce any output until the predicate first becomes false.
353
323
 
354
- <a name="groupby" href="#groupby">#</a> <b>groupby</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFcn: <i>T =&gt; Primitive</i>): <i>Iterable&lt;[Primitive, Iterable&lt;T&gt;]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
324
+ <a name="groupby" href="#groupby">#</a> <b>groupby</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFcn: <i>(item: T) =&gt; Primitive</i>): <i>Iterable&lt;[Primitive, Iterable&lt;T&gt;]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
355
325
 
356
326
  Make an Iterable that returns consecutive keys and groups from the iterable.
357
327
  The key is a function computing a key value for each element. If not specified,
@@ -367,116 +337,102 @@ common elements regardless of their input order.
367
337
  The returned group is itself an iterator that shares the underlying iterable
368
338
  with `groupby()`. Because the source is shared, when the `groupby()` object is
369
339
  advanced, the previous group is no longer visible. So, if that data is needed
370
- later, it should be stored as an Array.
371
-
340
+ later, it should be stored as an array.
372
341
 
373
- <a name="icompress" href="#icompress">#</a> <b>icompress</b>(iterable: <i>Iterable&lt;T&gt;</i>, selectors: <i>Iterable&lt;boolean&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
342
+ <a name="icompress" href="#icompress">#</a> <b>icompress</b>(iterable: <i>Iterable&lt;T&gt;</i>, selectors: <i>Iterable&lt;boolean&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
374
343
 
375
344
  Returns an iterator that filters elements from data returning only those that
376
- have a corresponding element in selectors that evaluates to `true`. Stops when
345
+ have a corresponding element in selectors that evaluates to `true`. Stops when
377
346
  either the data or selectors iterables has been exhausted.
378
347
 
379
-
380
- <a name="ifilter" href="#ifilter">#</a> <b>ifilter</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
348
+ <a name="ifilter" href="#ifilter">#</a> <b>ifilter</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
381
349
 
382
350
  Returns an iterator that filters elements from iterable returning only those
383
351
  for which the predicate is true.
384
352
 
385
- <a name="imap" href="#imap">#</a> <b>imap</b>(iterable: <i>Iterable&lt;T&gt;</i>, mapper: <i>T =&gt; V</i>): <i>Iterable&lt;V&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
353
+ <a name="imap" href="#imap">#</a> <b>imap</b>(iterable: <i>Iterable&lt;T&gt;</i>, mapper: <i>(item: T) =&gt; V</i>): <i>Iterable&lt;V&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
386
354
 
387
355
  Returns an iterator that computes the given mapper function using arguments
388
356
  from each of the iterables.
389
357
 
358
+ <a name="islice" href="#islice">#</a> <b>islice</b>(iterable: <i>Iterable&lt;T&gt;</i>[start: <i>number</i>], stop: <i>number</i>[, step: <i>number</i>]): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
390
359
 
391
- <a name="islice" href="#islice">#</a> <b>islice</b>(iterable: <i>Iterable&lt;T&gt;</i>[start: <i>number</i>], stop: <i>number</i>[, step: <i>number</i>]): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
392
-
393
- Returns an iterator that returns selected elements from the iterable. If
360
+ Returns an iterator that returns selected elements from the iterable. If
394
361
  `start` is non-zero, then elements from the iterable are skipped until start is
395
- reached. Then, elements are returned by making steps of `step` (defaults to
396
- 1). If set to higher than 1, items will be skipped. If `stop` is provided,
362
+ reached. Then, elements are returned by making steps of `step` (defaults to
363
+ 1). If set to higher than 1, items will be skipped. If `stop` is provided,
397
364
  then iteration continues until the iterator reached that index, otherwise, the
398
- iterable will be fully exhausted. `islice()` does not support negative values
365
+ iterable will be fully exhausted. `islice()` does not support negative values
399
366
  for `start`, `stop`, or `step`.
400
367
 
368
+ <a name="izip" href="#izip">#</a> <b>izip</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>): <i>Iterable&lt;[T1, T2]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')<br />
369
+ <a name="izip3" href="#izip3">#</a> <b>izip3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>): <i>Iterable&lt;[T1, T2, T3]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
401
370
 
402
- <a name="izip" href="#izip">#</a> <b>izip</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>): <i>Iterable&lt;[T1, T2]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")<br />
403
- <a name="izip3" href="#izip3">#</a> <b>izip3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>): <i>Iterable&lt;[T1, T2, T3]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
404
-
405
- Returns an iterator that aggregates elements from each of the iterables. Used
406
- for lock-step iteration over several iterables at a time. When iterating over
407
- two iterables, use `izip2`. When iterating over three iterables, use `izip3`,
408
- etc. `izip` is an alias for `izip2`.
371
+ Returns an iterator that aggregates elements from each of the iterables. Used
372
+ for lock-step iteration over several iterables at a time. When iterating over
373
+ two iterables, use `izip2`. When iterating over three iterables, use `izip3`,
374
+ etc. `izip` is an alias for `izip2`.
409
375
 
376
+ <a name="izipLongest" href="izipLongest">#</a> <b>izipLongest</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, filler?: <i>D</i>): <i>Iterable&lt;[T1 | D, T2 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')<br />
377
+ <a name="izipLongest3" href="izipLongest3">#</a> <b>izipLongest3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>, filler?: <i>D</i>): <i>Iterable&lt;[T1 | D, T2 | D, T3 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
410
378
 
411
- <a name="izipLongest" href="izipLongest">#</a> <b>izipLongest</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, filler?: <i>D</i>): <i>Iterable&lt;[T1 | D, T2 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")<br />
412
- <a name="izipLongest3" href="izipLongest3">#</a> <b>izipLongest3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>, filler?: <i>D</i>): <i>Iterable&lt;[T1 | D, T2 | D, T3 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
413
-
414
- Returns an iterator that aggregates elements from each of the iterables. If the
379
+ Returns an iterator that aggregates elements from each of the iterables. If the
415
380
  iterables are of uneven length, missing values are filled-in with fillvalue.
416
381
  Iteration continues until the longest iterable is exhausted.
417
382
 
418
-
419
- <a name="izipMany" href="#izipMany">#</a> <b>izipMany</b>(...iters: <i>Array&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;Array&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
383
+ <a name="izipMany" href="#izipMany">#</a> <b>izipMany</b>(...iters: <i>Iterable&lt;T&gt;[]</i>): <i>Iterable&lt;T[]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
420
384
 
421
385
  Like the other izips (`izip`, `izip3`, etc), but generalized to take an
422
- unlimited amount of input iterables. Think `izip(*iterables)` in Python.
423
-
424
- **Note:** Due to Flow type system limitations, you can only "generially" zip
425
- iterables with homogeneous types, so you cannot mix types like `<A, B>` like
426
- you can with `izip`().
427
-
386
+ unlimited amount of input iterables. Think `izip(*iterables)` in Python.
428
387
 
429
- <a name="permutations" href="#permutations">#</a> <b>permutations</b>(iterable: <i>Iterable&lt;T&gt;</i>, r: number = undefined): <i>Iterable&lt;Array<T>&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
388
+ <a name="permutations" href="#permutations">#</a> <b>permutations</b>(iterable: <i>Iterable&lt;T&gt;</i>, r: number = undefined): <i>Iterable&lt;T[]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
430
389
 
431
390
  Return successive `r`-length permutations of elements in the iterable.
432
391
 
433
392
  If `r` is not specified, then `r` defaults to the length of the iterable and
434
393
  all possible full-length permutations are generated.
435
394
 
436
- Permutations are emitted in lexicographic sort order. So, if the input
395
+ Permutations are emitted in lexicographic sort order. So, if the input
437
396
  iterable is sorted, the permutation tuples will be produced in sorted order.
438
397
 
439
- Elements are treated as unique based on their position, not on their value. So
398
+ Elements are treated as unique based on their position, not on their value. So
440
399
  if the input elements are unique, there will be no repeat values in each
441
400
  permutation.
442
401
 
402
+ <a name="repeat" href="#repeat">#</a> <b>repeat</b>(thing: <i>T</i>, times: number = undefined): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
443
403
 
444
- <a name="repeat" href="#repeat">#</a> <b>repeat</b>(thing: <i>T</i>, times: number = undefined): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
445
-
446
- Returns an iterator that produces values over and over again. Runs
404
+ Returns an iterator that produces values over and over again. Runs
447
405
  indefinitely unless the times argument is specified.
448
406
 
449
-
450
- <a name="takewhile" href="#takewhile">#</a> <b>takewhile</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>T =&gt; bool</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
407
+ <a name="takewhile" href="#takewhile">#</a> <b>takewhile</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>(item: T) =&gt; boolean</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
451
408
 
452
409
  Returns an iterator that produces elements from the iterable as long as the
453
410
  predicate is true.
454
411
 
455
- <a name="zipLongest" href="zipLongest">#</a> <b>zipLongest</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, filler?: <i>D</i>): <i>Array&lt;[T1 | D, T2 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")<br />
456
- <a name="zipLongest3" href="zipLongest3">#</a> <b>zipLongest3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>, filler?: <i>D</i>): <i>Array&lt;[T1 | D, T2 | D, T3 | D]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
457
-
458
- Non-lazy version of [izipLongest](#izipLongest) and friends.
412
+ <a name="zipLongest" href="zipLongest">#</a> <b>zipLongest</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, filler?: <i>D</i>): <i>[T1 | D, T2 | D][]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')<br />
413
+ <a name="zipLongest3" href="zipLongest3">#</a> <b>zipLongest3</b>(xs: <i>Iterable&lt;T1&gt;</i>, ys: <i>Iterable&lt;T2&gt;</i>, zs: <i>Iterable&lt;T3&gt;</i>, filler?: <i>D</i>): <i>[T1 | D, T2 | D, T3 | D][]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
459
414
 
460
- <a name="zipMany" href="#zipMany">#</a> <b>zipMany</b>(...iters: <i>Array&lt;Iterable&lt;T&gt;&gt;</i>): <i>Array&lt;Array&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js "Source")
415
+ Eager version of [izipLongest](#izipLongest) and friends.
461
416
 
462
- Non-lazy version of [izipMany](#izipMany).
417
+ <a name="zipMany" href="#zipMany">#</a> <b>zipMany</b>(...iters: <i>Iterable&lt;T&gt;[]</i>): <i>T[][]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/itertools.js 'Source')
463
418
 
419
+ Eager version of [izipMany](#izipMany).
464
420
 
465
421
  ### Ports of more-itertools
466
422
 
467
- * [chunked](#chunked)
468
- * [flatten](#flatten)
469
- * [intersperse](#intersperse)
470
- * [itake](#itake)
471
- * [pairwise](#pairwise)
472
- * [partition](#partition)
473
- * [roundrobin](#roundrobin)
474
- * [heads](#heads)
475
- * [take](#take)
476
- * [uniqueEverseen](#uniqueEverseen)
477
- * [uniqueJustseen](#uniqueJustseen)
423
+ - [chunked](#chunked)
424
+ - [flatten](#flatten)
425
+ - [intersperse](#intersperse)
426
+ - [itake](#itake)
427
+ - [pairwise](#pairwise)
428
+ - [partition](#partition)
429
+ - [roundrobin](#roundrobin)
430
+ - [heads](#heads)
431
+ - [take](#take)
432
+ - [uniqueEverseen](#uniqueEverseen)
433
+ - [uniqueJustseen](#uniqueJustseen)
478
434
 
479
- <a name="chunked" href="#chunked">#</a> <b>chunked</b>(iterable: <i>Iterable&lt;T&gt;</i>, size: <i>number</i>): <i>Iterable&lt;Array&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
435
+ <a name="chunked" href="#chunked">#</a> <b>chunked</b>(iterable: <i>Iterable&lt;T&gt;</i>, size: <i>number</i>): <i>Iterable&lt;T[]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
480
436
 
481
437
  Break iterable into lists of length `size`:
482
438
 
@@ -489,43 +445,38 @@ list will be shorter:
489
445
  >>> [...chunked([1, 2, 3, 4, 5, 6, 7, 8], 3)]
490
446
  [[1, 2, 3], [4, 5, 6], [7, 8]]
491
447
 
492
-
493
- <a name="flatten" href="#flatten">#</a> <b>flatten</b>(iterableOfIterables: <i>Iterable&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
448
+ <a name="flatten" href="#flatten">#</a> <b>flatten</b>(iterableOfIterables: <i>Iterable&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
494
449
 
495
450
  Return an iterator flattening one level of nesting in a list of lists:
496
451
 
497
452
  >>> [...flatten([[0, 1], [2, 3]])]
498
453
  [0, 1, 2, 3]
499
454
 
500
-
501
- <a name="intersperse" href="#intersperse">#</a> <b>intersperse</b>(value: T, iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
455
+ <a name="intersperse" href="#intersperse">#</a> <b>intersperse</b>(value: T, iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
502
456
 
503
457
  Intersperse filler element `value` among the items in `iterable`.
504
458
 
505
459
  >>> [...intersperse(-1, range(1, 5))]
506
460
  [1, -1, 2, -1, 3, -1, 4]
507
461
 
508
-
509
- <a name="itake" href="#itake">#</a> <b>itake</b>(n: <i>number</i>, iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
462
+ <a name="itake" href="#itake">#</a> <b>itake</b>(n: <i>number</i>, iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
510
463
 
511
464
  Returns an iterable containing only the first `n` elements of the given
512
465
  iterable.
513
466
 
467
+ <a name="pairwise" href="#pairwise">#</a> <b>pairwise</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;[T, T]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
514
468
 
515
- <a name="pairwise" href="#pairwise">#</a> <b>pairwise</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;[T, T]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
516
-
517
- Returns an iterator of paired items, overlapping, from the original. When the
469
+ Returns an iterator of paired items, overlapping, from the original. When the
518
470
  input iterable has a finite number of items `n`, the outputted iterable will
519
471
  have `n - 1` items.
520
472
 
521
473
  >>> pairwise([8, 2, 0, 7])
522
474
  [(8, 2), (2, 0), (0, 7)]
523
475
 
476
+ <a name="partition" href="#partition">#</a> <b>partition</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>[T[], T[]]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
524
477
 
525
- <a name="partition" href="#partition">#</a> <b>partition</b>(iterable: <i>Iterable&lt;T&gt;</i>, predicate: <i>Predicate&lt;T&gt;</i>): <i>[Array&lt;T&gt;, Array&lt;T&gt;]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
526
-
527
- Returns a 2-tuple of arrays. Splits the elements in the input iterable into
528
- either of the two arrays. Will fully exhaust the input iterable. The first
478
+ Returns a 2-tuple of arrays. Splits the elements in the input iterable into
479
+ either of the two arrays. Will fully exhaust the input iterable. The first
529
480
  array contains all items that match the predicate, the second the rest:
530
481
 
531
482
  >>> const isOdd = x => x % 2 !== 0;
@@ -536,8 +487,7 @@ array contains all items that match the predicate, the second the rest:
536
487
  >>> evens
537
488
  [0, 2, 4, 6, 8]
538
489
 
539
-
540
- <a name="roundrobin" href="#roundrobin">#</a> <b>roundrobin</b>(...iterables: <i>Array&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
490
+ <a name="roundrobin" href="#roundrobin">#</a> <b>roundrobin</b>(...iterables: <i>Iterable&lt;T&gt;[]</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
541
491
 
542
492
  Yields the next item from each iterable in turn, alternating between them.
543
493
  Continues until all items are exhausted.
@@ -545,21 +495,18 @@ Continues until all items are exhausted.
545
495
  >>> [...roundrobin([1, 2, 3], [4], [5, 6, 7, 8])]
546
496
  [1, 4, 5, 2, 6, 3, 7, 8]
547
497
 
548
-
549
- <a name="heads" href="#heads">#</a> <b>heads</b>(...iterables: <i>Array&lt;Iterable&lt;T&gt;&gt;</i>): <i>Iterable&lt;Array&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
498
+ <a name="heads" href="#heads">#</a> <b>heads</b>(...iterables: <i>Iterable&lt;T&gt;[]</i>): <i>Iterable&lt;T[]&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
550
499
 
551
500
  Like `roundrobin()`, but will group the output per "round".
552
501
 
553
502
  >>> [...heads([1, 2, 3], [4], [5, 6, 7, 8])]
554
503
  [[1, 4, 5], [2, 6], [3, 7], [8]]
555
504
 
505
+ <a name="take" href="#take">#</a> <b>take</b>(n: <i>number</i>, iterable: <i>Iterable&lt;T&gt;</i>): <i>T[]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
556
506
 
557
- <a name="take" href="#take">#</a> <b>take</b>(n: <i>number</i>, iterable: <i>Iterable&lt;T&gt;</i>): <i>Array&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
558
-
559
- Non-lazy version of [itake](#itake).
507
+ Eager version of [itake](#itake).
560
508
 
561
-
562
- <a name="uniqueEverseen" href="#uniqueEverseen">#</a> <b>uniqueEverseen</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>T =&gt; Primitive</i></i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
509
+ <a name="uniqueEverseen" href="#uniqueEverseen">#</a> <b>uniqueEverseen</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>(item: T) =&gt; Primitive</i></i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
563
510
 
564
511
  Yield unique elements, preserving order.
565
512
 
@@ -568,8 +515,7 @@ Yield unique elements, preserving order.
568
515
  >>> [...uniqueEverseen('AbBCcAB', s => s.toLowerCase())]
569
516
  ['A', 'b', 'C']
570
517
 
571
-
572
- <a name="uniqueJustseen" href="#uniqueJustseen">#</a> <b>uniqueJustseen</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>T =&gt; Primitive</i></i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js "Source")
518
+ <a name="uniqueJustseen" href="#uniqueJustseen">#</a> <b>uniqueJustseen</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>(item: T) =&gt; Primitive</i></i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/more-itertools.js 'Source')
573
519
 
574
520
  Yields elements in order, ignoring serial duplicates.
575
521
 
@@ -578,53 +524,46 @@ Yields elements in order, ignoring serial duplicates.
578
524
  >>> [...uniqueJustseen('AbBCcAB', s => s.toLowerCase())]
579
525
  ['A', 'b', 'C', 'A', 'B']
580
526
 
581
-
582
527
  ### Additions
583
528
 
584
- * [compact](#compact)
585
- * [compactObject](#compactObject)
586
- * [find](#find)
587
- * [first](#first)
588
- * [flatmap](#flatmap)
589
- * [icompact](#icompact)
590
-
591
- <a name="compact" href="#compact">#</a> <b>compact</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Array&lt;$NonMaybeType&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
592
-
593
- Non-lazy version of [icompact](#icompact).
529
+ - [compact](#compact)
530
+ - [compactObject](#compactObject)
531
+ - [find](#find)
532
+ - [first](#first)
533
+ - [flatmap](#flatmap)
534
+ - [icompact](#icompact)
594
535
 
536
+ <a name="compact" href="#compact">#</a> <b>compact</b>(iterable: <i>Iterable&lt;T | null | undefined&gt;</i>): <i>T[]</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
595
537
 
596
- <a name="compactObject" href="#compactObject">#</a> <b>compactObject</b><i>&lt;O: { [key: string]: * }&gt;</i>(obj: <i>O</i>): <i>$ObjMap&lt;O, &lt;T&gt;(T) =&gt; $NonMaybeType&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
538
+ Eager version of [icompact](#icompact).
597
539
 
598
- > **NOTE:** 🙀 OMG, that type signature! **Don't panic.** Just look at the example :)
540
+ <a name="compactObject" href="#compactObject">#</a> <b>compactObject</b>(obj: <i>Record&lt;K, V | null | undefined&gt;</i>): <i>Record&lt;K, V&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
599
541
 
600
- Removes all undefined values from the given object. Returns a new object.
542
+ Removes all "nullish" values from the given object. Returns a new object.
601
543
 
602
544
  >>> compactObject({ a: 1, b: undefined, c: 0, d: null })
603
545
  { a: 1, c: 0, d: null }
604
546
 
605
-
606
- <a name="find" href="#find">#</a> <b>find</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>Maybe&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
547
+ <a name="find" href="#find">#</a> <b>find</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>T | undefined</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
607
548
 
608
549
  Returns the first item in the iterable for which the predicate holds, if any.
609
- If no such item exists, `undefined` is returned. The default predicate is any
610
- defined value.
611
-
550
+ If no such item exists, `undefined` is returned. If no default predicate is
551
+ given, the first value from the iterable is returned.
612
552
 
613
- <a name="first" href="#first">#</a> <b>first</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>Maybe&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
553
+ <a name="first" href="#first">#</a> <b>first</b>(iterable: <i>Iterable&lt;T&gt;</i>, keyFn?: <i>Predicate&lt;T&gt;</i>): <i>T | undefined</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
614
554
 
615
555
  Almost the same as `find()`, except when no explicit predicate function is
616
556
  given. `find()` will always return the first value in the iterable, whereas
617
- `first()` will return the first non-undefined value in the iterable.
557
+ `first()` will return the first non-`undefined` value in the iterable.
618
558
 
619
559
  Prefer using `find()`, as its behavior is more intuitive and predictable.
620
560
 
561
+ <a name="flatmap" href="#flatmap">#</a> <b>flatmap</b>(iterable: <i>Iterable&lt;T&gt;</i>, mapper: <i>(item: T) =&gt; Iterable&lt;S&gt;</i>): <i>Iterable&lt;S&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
621
562
 
622
- <a name="flatmap" href="#flatmap">#</a> <b>flatmap</b>(iterable: <i>Iterable&lt;T&gt;</i>, mapper: <i>T =&gt; Iterable&lt;S&gt;</i>): <i>Iterable&lt;S&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
623
-
624
- Returns 0 or more values for every value in the given iterable. Technically,
563
+ Returns 0 or more values for every value in the given iterable. Technically,
625
564
  it's just calling map(), followed by flatten(), but it's a very useful
626
565
  operation if you want to map over a structure, but not have a 1:1 input-output
627
- mapping. Instead, if you want to potentially return 0 or more values per input
566
+ mapping. Instead, if you want to potentially return 0 or more values per input
628
567
  element, use flatmap():
629
568
 
630
569
  For example, to return all numbers `n` in the input iterable `n` times:
@@ -633,13 +572,10 @@ For example, to return all numbers `n` in the input iterable `n` times:
633
572
  >>> [...flatmap([0, 1, 2, 3, 4], repeatN)]
634
573
  [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] // note: no 0
635
574
 
575
+ <a name="icompact" href="#icompact">#</a> <b>icompact</b>(iterable: <i>Iterable&lt;T | null | undefined&gt;</i>): <i>Iterable&lt;T&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js 'Source')
636
576
 
637
- <a name="icompact" href="#icompact">#</a> <b>icompact</b>(iterable: <i>Iterable&lt;T&gt;</i>): <i>Iterable&lt;$NonMaybeType&lt;T&gt;&gt;</i> [&lt;&gt;](https://github.com/nvie/itertools.js/blob/master/src/custom.js "Source")
638
-
639
- Returns an iterable, filtering out any `undefined` values from the input
640
- iterable. This function is useful to convert a list of `Maybe<T>`'s to a list
641
- of `T`'s, discarding all the undefined values:
577
+ Returns an iterable, filtering out any "nullish" values from the input
578
+ iterable.
642
579
 
643
580
  >>> compact([1, 2, undefined, 3])
644
581
  [1, 2, 3]
645
-