itertools 2.0.0 → 2.1.1

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