itertools 1.7.1 → 2.0.0
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 +1 -1
- package/dist/index.d.mts +433 -0
- package/dist/index.d.ts +433 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -9
- package/CHANGELOG.md +0 -97
- package/builtins.d.ts +0 -18
- package/builtins.js +0 -467
- package/builtins.js.flow +0 -294
- package/custom.d.ts +0 -7
- package/custom.js +0 -186
- package/custom.js.flow +0 -82
- package/index.d.ts +0 -52
- package/index.js +0 -307
- package/index.js.flow +0 -57
- package/itertools.d.ts +0 -52
- package/itertools.js +0 -1287
- package/itertools.js.flow +0 -423
- package/more-itertools.d.ts +0 -13
- package/more-itertools.js +0 -739
- package/more-itertools.js.flow +0 -261
- package/types.d.ts +0 -3
- package/types.js +0 -1
- package/types.js.flow +0 -5
- package/utils.d.ts +0 -8
- package/utils.js +0 -48
- package/utils.js.flow +0 -42
package/itertools.js
DELETED
|
@@ -1,1287 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.chain = chain;
|
|
7
|
-
exports.count = count;
|
|
8
|
-
exports.compress = compress;
|
|
9
|
-
exports.cycle = cycle;
|
|
10
|
-
exports.dropwhile = dropwhile;
|
|
11
|
-
exports.groupby = groupby;
|
|
12
|
-
exports.icompress = icompress;
|
|
13
|
-
exports.ifilter = ifilter;
|
|
14
|
-
exports.imap = imap;
|
|
15
|
-
exports.islice = islice;
|
|
16
|
-
exports.izip2 = izip2;
|
|
17
|
-
exports.izip3 = izip3;
|
|
18
|
-
exports.izipLongest2 = izipLongest2;
|
|
19
|
-
exports.izipLongest3 = izipLongest3;
|
|
20
|
-
exports.izipMany = izipMany;
|
|
21
|
-
exports.permutations = permutations;
|
|
22
|
-
exports.repeat = repeat;
|
|
23
|
-
exports.takewhile = takewhile;
|
|
24
|
-
exports.zipLongest2 = zipLongest2;
|
|
25
|
-
exports.zipLongest3 = zipLongest3;
|
|
26
|
-
exports.zipMany = zipMany;
|
|
27
|
-
exports.zipLongest = exports.izipLongest = exports.izip = void 0;
|
|
28
|
-
|
|
29
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
30
|
-
|
|
31
|
-
var _builtins = require("./builtins");
|
|
32
|
-
|
|
33
|
-
var _moreItertools = require("./more-itertools");
|
|
34
|
-
|
|
35
|
-
var _utils = require("./utils");
|
|
36
|
-
|
|
37
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
38
|
-
|
|
39
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
40
|
-
|
|
41
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
42
|
-
|
|
43
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
44
|
-
|
|
45
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
46
|
-
|
|
47
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
48
|
-
|
|
49
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
50
|
-
|
|
51
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
52
|
-
|
|
53
|
-
var _marked = /*#__PURE__*/_regenerator["default"].mark(count),
|
|
54
|
-
_marked2 = /*#__PURE__*/_regenerator["default"].mark(cycle),
|
|
55
|
-
_marked3 = /*#__PURE__*/_regenerator["default"].mark(dropwhile),
|
|
56
|
-
_marked4 = /*#__PURE__*/_regenerator["default"].mark(groupby),
|
|
57
|
-
_marked5 = /*#__PURE__*/_regenerator["default"].mark(icompress),
|
|
58
|
-
_marked6 = /*#__PURE__*/_regenerator["default"].mark(ifilter),
|
|
59
|
-
_marked7 = /*#__PURE__*/_regenerator["default"].mark(imap),
|
|
60
|
-
_marked8 = /*#__PURE__*/_regenerator["default"].mark(islice),
|
|
61
|
-
_marked9 = /*#__PURE__*/_regenerator["default"].mark(izip2),
|
|
62
|
-
_marked10 = /*#__PURE__*/_regenerator["default"].mark(izip3),
|
|
63
|
-
_marked11 = /*#__PURE__*/_regenerator["default"].mark(izipLongest2),
|
|
64
|
-
_marked12 = /*#__PURE__*/_regenerator["default"].mark(izipLongest3),
|
|
65
|
-
_marked13 = /*#__PURE__*/_regenerator["default"].mark(izipMany),
|
|
66
|
-
_marked14 = /*#__PURE__*/_regenerator["default"].mark(permutations),
|
|
67
|
-
_marked15 = /*#__PURE__*/_regenerator["default"].mark(repeat),
|
|
68
|
-
_marked16 = /*#__PURE__*/_regenerator["default"].mark(takewhile);
|
|
69
|
-
|
|
70
|
-
var SENTINEL = Symbol();
|
|
71
|
-
|
|
72
|
-
function composeAnd(f1, f2) {
|
|
73
|
-
return function (n) {
|
|
74
|
-
return f1(n) && f2(n);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function slicePredicate(start, stop, step) {
|
|
79
|
-
// If stop is not provided (= undefined), then interpret the start value as the stop value
|
|
80
|
-
var _start = start,
|
|
81
|
-
_stop = stop,
|
|
82
|
-
_step = step;
|
|
83
|
-
|
|
84
|
-
if (_stop === undefined) {
|
|
85
|
-
var _ref = [0, _start];
|
|
86
|
-
_start = _ref[0];
|
|
87
|
-
_stop = _ref[1];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var pred = function pred(n) {
|
|
91
|
-
return n >= _start;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (_stop !== null) {
|
|
95
|
-
var stopNotNull = _stop;
|
|
96
|
-
pred = composeAnd(pred, function (n) {
|
|
97
|
-
return n < stopNotNull;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (_step > 1) {
|
|
102
|
-
pred = composeAnd(pred, function (n) {
|
|
103
|
-
return (n - _start) % _step === 0;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return pred;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns an iterator that returns elements from the first iterable until it
|
|
111
|
-
* is exhausted, then proceeds to the next iterable, until all of the iterables
|
|
112
|
-
* are exhausted. Used for treating consecutive sequences as a single
|
|
113
|
-
* sequence.
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function chain() {
|
|
118
|
-
for (var _len = arguments.length, iterables = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
119
|
-
iterables[_key] = arguments[_key];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return (0, _moreItertools.flatten)(iterables);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Returns an iterator that counts up values starting with number `start`
|
|
126
|
-
* (default 0), incrementing by `step`. To decrement, use a negative step
|
|
127
|
-
* number.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function count() {
|
|
132
|
-
var start,
|
|
133
|
-
step,
|
|
134
|
-
n,
|
|
135
|
-
_args = arguments;
|
|
136
|
-
return _regenerator["default"].wrap(function count$(_context) {
|
|
137
|
-
while (1) {
|
|
138
|
-
switch (_context.prev = _context.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
start = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
|
|
141
|
-
step = _args.length > 1 && _args[1] !== undefined ? _args[1] : 1;
|
|
142
|
-
n = start;
|
|
143
|
-
|
|
144
|
-
case 3:
|
|
145
|
-
_context.next = 5;
|
|
146
|
-
return n;
|
|
147
|
-
|
|
148
|
-
case 5:
|
|
149
|
-
n += step;
|
|
150
|
-
|
|
151
|
-
case 6:
|
|
152
|
-
_context.next = 3;
|
|
153
|
-
break;
|
|
154
|
-
|
|
155
|
-
case 8:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context.stop();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, _marked);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Non-lazy version of icompress().
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function compress(data, selectors) {
|
|
168
|
-
return Array.from(icompress(data, selectors));
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Returns an iterator producing elements from the iterable and saving a copy
|
|
172
|
-
* of each. When the iterable is exhausted, return elements from the saved
|
|
173
|
-
* copy. Repeats indefinitely.
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
function cycle(iterable) {
|
|
178
|
-
var saved, _iterator, _step2, _element, _iterator2, _step3, element;
|
|
179
|
-
|
|
180
|
-
return _regenerator["default"].wrap(function cycle$(_context2) {
|
|
181
|
-
while (1) {
|
|
182
|
-
switch (_context2.prev = _context2.next) {
|
|
183
|
-
case 0:
|
|
184
|
-
saved = [];
|
|
185
|
-
_iterator = _createForOfIteratorHelper(iterable);
|
|
186
|
-
_context2.prev = 2;
|
|
187
|
-
|
|
188
|
-
_iterator.s();
|
|
189
|
-
|
|
190
|
-
case 4:
|
|
191
|
-
if ((_step2 = _iterator.n()).done) {
|
|
192
|
-
_context2.next = 11;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
_element = _step2.value;
|
|
197
|
-
_context2.next = 8;
|
|
198
|
-
return _element;
|
|
199
|
-
|
|
200
|
-
case 8:
|
|
201
|
-
saved.push(_element);
|
|
202
|
-
|
|
203
|
-
case 9:
|
|
204
|
-
_context2.next = 4;
|
|
205
|
-
break;
|
|
206
|
-
|
|
207
|
-
case 11:
|
|
208
|
-
_context2.next = 16;
|
|
209
|
-
break;
|
|
210
|
-
|
|
211
|
-
case 13:
|
|
212
|
-
_context2.prev = 13;
|
|
213
|
-
_context2.t0 = _context2["catch"](2);
|
|
214
|
-
|
|
215
|
-
_iterator.e(_context2.t0);
|
|
216
|
-
|
|
217
|
-
case 16:
|
|
218
|
-
_context2.prev = 16;
|
|
219
|
-
|
|
220
|
-
_iterator.f();
|
|
221
|
-
|
|
222
|
-
return _context2.finish(16);
|
|
223
|
-
|
|
224
|
-
case 19:
|
|
225
|
-
if (!(saved.length > 0)) {
|
|
226
|
-
_context2.next = 39;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
_iterator2 = _createForOfIteratorHelper(saved);
|
|
231
|
-
_context2.prev = 21;
|
|
232
|
-
|
|
233
|
-
_iterator2.s();
|
|
234
|
-
|
|
235
|
-
case 23:
|
|
236
|
-
if ((_step3 = _iterator2.n()).done) {
|
|
237
|
-
_context2.next = 29;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
element = _step3.value;
|
|
242
|
-
_context2.next = 27;
|
|
243
|
-
return element;
|
|
244
|
-
|
|
245
|
-
case 27:
|
|
246
|
-
_context2.next = 23;
|
|
247
|
-
break;
|
|
248
|
-
|
|
249
|
-
case 29:
|
|
250
|
-
_context2.next = 34;
|
|
251
|
-
break;
|
|
252
|
-
|
|
253
|
-
case 31:
|
|
254
|
-
_context2.prev = 31;
|
|
255
|
-
_context2.t1 = _context2["catch"](21);
|
|
256
|
-
|
|
257
|
-
_iterator2.e(_context2.t1);
|
|
258
|
-
|
|
259
|
-
case 34:
|
|
260
|
-
_context2.prev = 34;
|
|
261
|
-
|
|
262
|
-
_iterator2.f();
|
|
263
|
-
|
|
264
|
-
return _context2.finish(34);
|
|
265
|
-
|
|
266
|
-
case 37:
|
|
267
|
-
_context2.next = 19;
|
|
268
|
-
break;
|
|
269
|
-
|
|
270
|
-
case 39:
|
|
271
|
-
case "end":
|
|
272
|
-
return _context2.stop();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}, _marked2, null, [[2, 13, 16, 19], [21, 31, 34, 37]]);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Returns an iterator that drops elements from the iterable as long as the
|
|
279
|
-
* predicate is true; afterwards, returns every remaining element. Note, the
|
|
280
|
-
* iterator does not produce any output until the predicate first becomes
|
|
281
|
-
* false.
|
|
282
|
-
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
function dropwhile(iterable, predicate) {
|
|
286
|
-
var it, _iterator3, _step4, value, _iterator4, _step5, _value;
|
|
287
|
-
|
|
288
|
-
return _regenerator["default"].wrap(function dropwhile$(_context3) {
|
|
289
|
-
while (1) {
|
|
290
|
-
switch (_context3.prev = _context3.next) {
|
|
291
|
-
case 0:
|
|
292
|
-
it = (0, _builtins.iter)(iterable);
|
|
293
|
-
_iterator3 = _createForOfIteratorHelper(it);
|
|
294
|
-
_context3.prev = 2;
|
|
295
|
-
|
|
296
|
-
_iterator3.s();
|
|
297
|
-
|
|
298
|
-
case 4:
|
|
299
|
-
if ((_step4 = _iterator3.n()).done) {
|
|
300
|
-
_context3.next = 12;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
value = _step4.value;
|
|
305
|
-
|
|
306
|
-
if (predicate(value)) {
|
|
307
|
-
_context3.next = 10;
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
_context3.next = 9;
|
|
312
|
-
return value;
|
|
313
|
-
|
|
314
|
-
case 9:
|
|
315
|
-
return _context3.abrupt("break", 12);
|
|
316
|
-
|
|
317
|
-
case 10:
|
|
318
|
-
_context3.next = 4;
|
|
319
|
-
break;
|
|
320
|
-
|
|
321
|
-
case 12:
|
|
322
|
-
_context3.next = 17;
|
|
323
|
-
break;
|
|
324
|
-
|
|
325
|
-
case 14:
|
|
326
|
-
_context3.prev = 14;
|
|
327
|
-
_context3.t0 = _context3["catch"](2);
|
|
328
|
-
|
|
329
|
-
_iterator3.e(_context3.t0);
|
|
330
|
-
|
|
331
|
-
case 17:
|
|
332
|
-
_context3.prev = 17;
|
|
333
|
-
|
|
334
|
-
_iterator3.f();
|
|
335
|
-
|
|
336
|
-
return _context3.finish(17);
|
|
337
|
-
|
|
338
|
-
case 20:
|
|
339
|
-
_iterator4 = _createForOfIteratorHelper(it);
|
|
340
|
-
_context3.prev = 21;
|
|
341
|
-
|
|
342
|
-
_iterator4.s();
|
|
343
|
-
|
|
344
|
-
case 23:
|
|
345
|
-
if ((_step5 = _iterator4.n()).done) {
|
|
346
|
-
_context3.next = 29;
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
_value = _step5.value;
|
|
351
|
-
_context3.next = 27;
|
|
352
|
-
return _value;
|
|
353
|
-
|
|
354
|
-
case 27:
|
|
355
|
-
_context3.next = 23;
|
|
356
|
-
break;
|
|
357
|
-
|
|
358
|
-
case 29:
|
|
359
|
-
_context3.next = 34;
|
|
360
|
-
break;
|
|
361
|
-
|
|
362
|
-
case 31:
|
|
363
|
-
_context3.prev = 31;
|
|
364
|
-
_context3.t1 = _context3["catch"](21);
|
|
365
|
-
|
|
366
|
-
_iterator4.e(_context3.t1);
|
|
367
|
-
|
|
368
|
-
case 34:
|
|
369
|
-
_context3.prev = 34;
|
|
370
|
-
|
|
371
|
-
_iterator4.f();
|
|
372
|
-
|
|
373
|
-
return _context3.finish(34);
|
|
374
|
-
|
|
375
|
-
case 37:
|
|
376
|
-
case "end":
|
|
377
|
-
return _context3.stop();
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}, _marked3, null, [[2, 14, 17, 20], [21, 31, 34, 37]]);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function groupby(iterable) {
|
|
384
|
-
var keyFn,
|
|
385
|
-
it,
|
|
386
|
-
currentValue,
|
|
387
|
-
currentKey,
|
|
388
|
-
targetKey,
|
|
389
|
-
grouper,
|
|
390
|
-
nextVal,
|
|
391
|
-
_args5 = arguments;
|
|
392
|
-
return _regenerator["default"].wrap(function groupby$(_context5) {
|
|
393
|
-
while (1) {
|
|
394
|
-
switch (_context5.prev = _context5.next) {
|
|
395
|
-
case 0:
|
|
396
|
-
keyFn = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : _utils.primitiveIdentity;
|
|
397
|
-
it = (0, _builtins.iter)(iterable);
|
|
398
|
-
// $FlowFixMe[incompatible-type] - deliberate use of the SENTINEL symbol
|
|
399
|
-
currentKey = SENTINEL;
|
|
400
|
-
targetKey = currentKey;
|
|
401
|
-
grouper = /*#__PURE__*/_regenerator["default"].mark(function grouper(tgtKey) {
|
|
402
|
-
var nextVal;
|
|
403
|
-
return _regenerator["default"].wrap(function grouper$(_context4) {
|
|
404
|
-
while (1) {
|
|
405
|
-
switch (_context4.prev = _context4.next) {
|
|
406
|
-
case 0:
|
|
407
|
-
if (!(currentKey === tgtKey)) {
|
|
408
|
-
_context4.next = 10;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
_context4.next = 3;
|
|
413
|
-
return currentValue;
|
|
414
|
-
|
|
415
|
-
case 3:
|
|
416
|
-
nextVal = it.next();
|
|
417
|
-
|
|
418
|
-
if (!nextVal.done) {
|
|
419
|
-
_context4.next = 6;
|
|
420
|
-
break;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return _context4.abrupt("return");
|
|
424
|
-
|
|
425
|
-
case 6:
|
|
426
|
-
currentValue = nextVal.value;
|
|
427
|
-
currentKey = keyFn(currentValue);
|
|
428
|
-
_context4.next = 0;
|
|
429
|
-
break;
|
|
430
|
-
|
|
431
|
-
case 10:
|
|
432
|
-
case "end":
|
|
433
|
-
return _context4.stop();
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}, grouper);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
case 5:
|
|
440
|
-
if (!(currentKey === targetKey)) {
|
|
441
|
-
_context5.next = 14;
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
nextVal = it.next();
|
|
446
|
-
|
|
447
|
-
if (!nextVal.done) {
|
|
448
|
-
_context5.next = 10;
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// $FlowFixMe[incompatible-type] - deliberate use of the SENTINEL symbol
|
|
453
|
-
currentKey = SENTINEL;
|
|
454
|
-
return _context5.abrupt("return");
|
|
455
|
-
|
|
456
|
-
case 10:
|
|
457
|
-
currentValue = nextVal.value;
|
|
458
|
-
currentKey = keyFn(currentValue);
|
|
459
|
-
_context5.next = 5;
|
|
460
|
-
break;
|
|
461
|
-
|
|
462
|
-
case 14:
|
|
463
|
-
targetKey = currentKey;
|
|
464
|
-
_context5.next = 17;
|
|
465
|
-
return [currentKey, grouper(targetKey)];
|
|
466
|
-
|
|
467
|
-
case 17:
|
|
468
|
-
_context5.next = 5;
|
|
469
|
-
break;
|
|
470
|
-
|
|
471
|
-
case 19:
|
|
472
|
-
case "end":
|
|
473
|
-
return _context5.stop();
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}, _marked4);
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Returns an iterator that filters elements from data returning only those
|
|
480
|
-
* that have a corresponding element in selectors that evaluates to `true`.
|
|
481
|
-
* Stops when either the data or selectors iterables has been exhausted.
|
|
482
|
-
*/
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
function icompress(data, selectors) {
|
|
486
|
-
var _iterator5, _step6, _step6$value, d, s;
|
|
487
|
-
|
|
488
|
-
return _regenerator["default"].wrap(function icompress$(_context6) {
|
|
489
|
-
while (1) {
|
|
490
|
-
switch (_context6.prev = _context6.next) {
|
|
491
|
-
case 0:
|
|
492
|
-
_iterator5 = _createForOfIteratorHelper(izip(data, selectors));
|
|
493
|
-
_context6.prev = 1;
|
|
494
|
-
|
|
495
|
-
_iterator5.s();
|
|
496
|
-
|
|
497
|
-
case 3:
|
|
498
|
-
if ((_step6 = _iterator5.n()).done) {
|
|
499
|
-
_context6.next = 10;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
_step6$value = _slicedToArray(_step6.value, 2), d = _step6$value[0], s = _step6$value[1];
|
|
504
|
-
|
|
505
|
-
if (!s) {
|
|
506
|
-
_context6.next = 8;
|
|
507
|
-
break;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
_context6.next = 8;
|
|
511
|
-
return d;
|
|
512
|
-
|
|
513
|
-
case 8:
|
|
514
|
-
_context6.next = 3;
|
|
515
|
-
break;
|
|
516
|
-
|
|
517
|
-
case 10:
|
|
518
|
-
_context6.next = 15;
|
|
519
|
-
break;
|
|
520
|
-
|
|
521
|
-
case 12:
|
|
522
|
-
_context6.prev = 12;
|
|
523
|
-
_context6.t0 = _context6["catch"](1);
|
|
524
|
-
|
|
525
|
-
_iterator5.e(_context6.t0);
|
|
526
|
-
|
|
527
|
-
case 15:
|
|
528
|
-
_context6.prev = 15;
|
|
529
|
-
|
|
530
|
-
_iterator5.f();
|
|
531
|
-
|
|
532
|
-
return _context6.finish(15);
|
|
533
|
-
|
|
534
|
-
case 18:
|
|
535
|
-
case "end":
|
|
536
|
-
return _context6.stop();
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}, _marked5, null, [[1, 12, 15, 18]]);
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Returns an iterator that filters elements from iterable returning only those
|
|
543
|
-
* for which the predicate is true.
|
|
544
|
-
*/
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
function ifilter(iterable, predicate) {
|
|
548
|
-
var _iterator6, _step7, value;
|
|
549
|
-
|
|
550
|
-
return _regenerator["default"].wrap(function ifilter$(_context7) {
|
|
551
|
-
while (1) {
|
|
552
|
-
switch (_context7.prev = _context7.next) {
|
|
553
|
-
case 0:
|
|
554
|
-
_iterator6 = _createForOfIteratorHelper(iterable);
|
|
555
|
-
_context7.prev = 1;
|
|
556
|
-
|
|
557
|
-
_iterator6.s();
|
|
558
|
-
|
|
559
|
-
case 3:
|
|
560
|
-
if ((_step7 = _iterator6.n()).done) {
|
|
561
|
-
_context7.next = 10;
|
|
562
|
-
break;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
value = _step7.value;
|
|
566
|
-
|
|
567
|
-
if (!predicate(value)) {
|
|
568
|
-
_context7.next = 8;
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
_context7.next = 8;
|
|
573
|
-
return value;
|
|
574
|
-
|
|
575
|
-
case 8:
|
|
576
|
-
_context7.next = 3;
|
|
577
|
-
break;
|
|
578
|
-
|
|
579
|
-
case 10:
|
|
580
|
-
_context7.next = 15;
|
|
581
|
-
break;
|
|
582
|
-
|
|
583
|
-
case 12:
|
|
584
|
-
_context7.prev = 12;
|
|
585
|
-
_context7.t0 = _context7["catch"](1);
|
|
586
|
-
|
|
587
|
-
_iterator6.e(_context7.t0);
|
|
588
|
-
|
|
589
|
-
case 15:
|
|
590
|
-
_context7.prev = 15;
|
|
591
|
-
|
|
592
|
-
_iterator6.f();
|
|
593
|
-
|
|
594
|
-
return _context7.finish(15);
|
|
595
|
-
|
|
596
|
-
case 18:
|
|
597
|
-
case "end":
|
|
598
|
-
return _context7.stop();
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}, _marked6, null, [[1, 12, 15, 18]]);
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Returns an iterator that computes the given mapper function using arguments
|
|
605
|
-
* from each of the iterables.
|
|
606
|
-
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
function imap(iterable, mapper) {
|
|
610
|
-
var _iterator7, _step8, value;
|
|
611
|
-
|
|
612
|
-
return _regenerator["default"].wrap(function imap$(_context8) {
|
|
613
|
-
while (1) {
|
|
614
|
-
switch (_context8.prev = _context8.next) {
|
|
615
|
-
case 0:
|
|
616
|
-
_iterator7 = _createForOfIteratorHelper(iterable);
|
|
617
|
-
_context8.prev = 1;
|
|
618
|
-
|
|
619
|
-
_iterator7.s();
|
|
620
|
-
|
|
621
|
-
case 3:
|
|
622
|
-
if ((_step8 = _iterator7.n()).done) {
|
|
623
|
-
_context8.next = 9;
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
value = _step8.value;
|
|
628
|
-
_context8.next = 7;
|
|
629
|
-
return mapper(value);
|
|
630
|
-
|
|
631
|
-
case 7:
|
|
632
|
-
_context8.next = 3;
|
|
633
|
-
break;
|
|
634
|
-
|
|
635
|
-
case 9:
|
|
636
|
-
_context8.next = 14;
|
|
637
|
-
break;
|
|
638
|
-
|
|
639
|
-
case 11:
|
|
640
|
-
_context8.prev = 11;
|
|
641
|
-
_context8.t0 = _context8["catch"](1);
|
|
642
|
-
|
|
643
|
-
_iterator7.e(_context8.t0);
|
|
644
|
-
|
|
645
|
-
case 14:
|
|
646
|
-
_context8.prev = 14;
|
|
647
|
-
|
|
648
|
-
_iterator7.f();
|
|
649
|
-
|
|
650
|
-
return _context8.finish(14);
|
|
651
|
-
|
|
652
|
-
case 17:
|
|
653
|
-
case "end":
|
|
654
|
-
return _context8.stop();
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}, _marked7, null, [[1, 11, 14, 17]]);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Returns an iterator that returns selected elements from the iterable. If
|
|
661
|
-
* `start` is non-zero, then elements from the iterable are skipped until start
|
|
662
|
-
* is reached. Then, elements are returned by making steps of `step` (defaults
|
|
663
|
-
* to 1). If set to higher than 1, items will be skipped. If `stop` is
|
|
664
|
-
* provided, then iteration continues until the iterator reached that index,
|
|
665
|
-
* otherwise, the iterable will be fully exhausted. `islice()` does not
|
|
666
|
-
* support negative values for `start`, `stop`, or `step`.
|
|
667
|
-
*/
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
function islice(iterable, start, stop) {
|
|
671
|
-
var step,
|
|
672
|
-
pred,
|
|
673
|
-
_iterator8,
|
|
674
|
-
_step9,
|
|
675
|
-
_step9$value,
|
|
676
|
-
i,
|
|
677
|
-
value,
|
|
678
|
-
_args9 = arguments;
|
|
679
|
-
|
|
680
|
-
return _regenerator["default"].wrap(function islice$(_context9) {
|
|
681
|
-
while (1) {
|
|
682
|
-
switch (_context9.prev = _context9.next) {
|
|
683
|
-
case 0:
|
|
684
|
-
step = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : 1;
|
|
685
|
-
|
|
686
|
-
if (!(start < 0)) {
|
|
687
|
-
_context9.next = 3;
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
throw new Error('start cannot be negative');
|
|
692
|
-
|
|
693
|
-
case 3:
|
|
694
|
-
if (!(typeof stop === 'number' && stop < 0)) {
|
|
695
|
-
_context9.next = 5;
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
throw new Error('stop cannot be negative');
|
|
700
|
-
|
|
701
|
-
case 5:
|
|
702
|
-
if (!(step < 0)) {
|
|
703
|
-
_context9.next = 7;
|
|
704
|
-
break;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
throw new Error('step cannot be negative');
|
|
708
|
-
|
|
709
|
-
case 7:
|
|
710
|
-
pred = slicePredicate(start, stop, step);
|
|
711
|
-
_iterator8 = _createForOfIteratorHelper((0, _builtins.enumerate)(iterable));
|
|
712
|
-
_context9.prev = 9;
|
|
713
|
-
|
|
714
|
-
_iterator8.s();
|
|
715
|
-
|
|
716
|
-
case 11:
|
|
717
|
-
if ((_step9 = _iterator8.n()).done) {
|
|
718
|
-
_context9.next = 18;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
_step9$value = _slicedToArray(_step9.value, 2), i = _step9$value[0], value = _step9$value[1];
|
|
723
|
-
|
|
724
|
-
if (!pred(i)) {
|
|
725
|
-
_context9.next = 16;
|
|
726
|
-
break;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
_context9.next = 16;
|
|
730
|
-
return value;
|
|
731
|
-
|
|
732
|
-
case 16:
|
|
733
|
-
_context9.next = 11;
|
|
734
|
-
break;
|
|
735
|
-
|
|
736
|
-
case 18:
|
|
737
|
-
_context9.next = 23;
|
|
738
|
-
break;
|
|
739
|
-
|
|
740
|
-
case 20:
|
|
741
|
-
_context9.prev = 20;
|
|
742
|
-
_context9.t0 = _context9["catch"](9);
|
|
743
|
-
|
|
744
|
-
_iterator8.e(_context9.t0);
|
|
745
|
-
|
|
746
|
-
case 23:
|
|
747
|
-
_context9.prev = 23;
|
|
748
|
-
|
|
749
|
-
_iterator8.f();
|
|
750
|
-
|
|
751
|
-
return _context9.finish(23);
|
|
752
|
-
|
|
753
|
-
case 26:
|
|
754
|
-
case "end":
|
|
755
|
-
return _context9.stop();
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}, _marked8, null, [[9, 20, 23, 26]]);
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Returns an iterator that aggregates elements from each of the iterables.
|
|
762
|
-
* Used for lock-step iteration over several iterables at a time. When
|
|
763
|
-
* iterating over two iterables, use `izip2`. When iterating over three
|
|
764
|
-
* iterables, use `izip3`, etc. `izip` is an alias for `izip2`.
|
|
765
|
-
*/
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
function izip2(xs, ys) {
|
|
769
|
-
var ixs, iys, x, y;
|
|
770
|
-
return _regenerator["default"].wrap(function izip2$(_context10) {
|
|
771
|
-
while (1) {
|
|
772
|
-
switch (_context10.prev = _context10.next) {
|
|
773
|
-
case 0:
|
|
774
|
-
ixs = (0, _builtins.iter)(xs);
|
|
775
|
-
iys = (0, _builtins.iter)(ys);
|
|
776
|
-
|
|
777
|
-
case 2:
|
|
778
|
-
x = ixs.next();
|
|
779
|
-
y = iys.next();
|
|
780
|
-
|
|
781
|
-
if (!(!x.done && !y.done)) {
|
|
782
|
-
_context10.next = 9;
|
|
783
|
-
break;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
_context10.next = 7;
|
|
787
|
-
return [x.value, y.value];
|
|
788
|
-
|
|
789
|
-
case 7:
|
|
790
|
-
_context10.next = 10;
|
|
791
|
-
break;
|
|
792
|
-
|
|
793
|
-
case 9:
|
|
794
|
-
return _context10.abrupt("return");
|
|
795
|
-
|
|
796
|
-
case 10:
|
|
797
|
-
_context10.next = 2;
|
|
798
|
-
break;
|
|
799
|
-
|
|
800
|
-
case 12:
|
|
801
|
-
case "end":
|
|
802
|
-
return _context10.stop();
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}, _marked9);
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* Like izip2, but for three input iterables.
|
|
809
|
-
*/
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
function izip3(xs, ys, zs) {
|
|
813
|
-
var ixs, iys, izs, x, y, z;
|
|
814
|
-
return _regenerator["default"].wrap(function izip3$(_context11) {
|
|
815
|
-
while (1) {
|
|
816
|
-
switch (_context11.prev = _context11.next) {
|
|
817
|
-
case 0:
|
|
818
|
-
ixs = (0, _builtins.iter)(xs);
|
|
819
|
-
iys = (0, _builtins.iter)(ys);
|
|
820
|
-
izs = (0, _builtins.iter)(zs);
|
|
821
|
-
|
|
822
|
-
case 3:
|
|
823
|
-
x = ixs.next();
|
|
824
|
-
y = iys.next();
|
|
825
|
-
z = izs.next();
|
|
826
|
-
|
|
827
|
-
if (!(!x.done && !y.done && !z.done)) {
|
|
828
|
-
_context11.next = 11;
|
|
829
|
-
break;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
_context11.next = 9;
|
|
833
|
-
return [x.value, y.value, z.value];
|
|
834
|
-
|
|
835
|
-
case 9:
|
|
836
|
-
_context11.next = 12;
|
|
837
|
-
break;
|
|
838
|
-
|
|
839
|
-
case 11:
|
|
840
|
-
return _context11.abrupt("return");
|
|
841
|
-
|
|
842
|
-
case 12:
|
|
843
|
-
_context11.next = 3;
|
|
844
|
-
break;
|
|
845
|
-
|
|
846
|
-
case 14:
|
|
847
|
-
case "end":
|
|
848
|
-
return _context11.stop();
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}, _marked10);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
var izip = izip2;
|
|
855
|
-
/**
|
|
856
|
-
* Returns an iterator that aggregates elements from each of the iterables. If
|
|
857
|
-
* the iterables are of uneven length, missing values are filled-in with
|
|
858
|
-
* fillvalue. Iteration continues until the longest iterable is exhausted.
|
|
859
|
-
*/
|
|
860
|
-
|
|
861
|
-
exports.izip = izip;
|
|
862
|
-
|
|
863
|
-
function izipLongest2(xs, ys, filler) {
|
|
864
|
-
var ixs, iys, x, y;
|
|
865
|
-
return _regenerator["default"].wrap(function izipLongest2$(_context12) {
|
|
866
|
-
while (1) {
|
|
867
|
-
switch (_context12.prev = _context12.next) {
|
|
868
|
-
case 0:
|
|
869
|
-
ixs = (0, _builtins.iter)(xs);
|
|
870
|
-
iys = (0, _builtins.iter)(ys);
|
|
871
|
-
|
|
872
|
-
case 2:
|
|
873
|
-
x = ixs.next();
|
|
874
|
-
y = iys.next();
|
|
875
|
-
|
|
876
|
-
if (!(x.done && y.done)) {
|
|
877
|
-
_context12.next = 8;
|
|
878
|
-
break;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
return _context12.abrupt("return");
|
|
882
|
-
|
|
883
|
-
case 8:
|
|
884
|
-
_context12.next = 10;
|
|
885
|
-
return [!x.done ? x.value : filler, !y.done ? y.value : filler];
|
|
886
|
-
|
|
887
|
-
case 10:
|
|
888
|
-
_context12.next = 2;
|
|
889
|
-
break;
|
|
890
|
-
|
|
891
|
-
case 12:
|
|
892
|
-
case "end":
|
|
893
|
-
return _context12.stop();
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}, _marked11);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* See izipLongest2, but for three.
|
|
900
|
-
*/
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
function izipLongest3(xs, ys, zs, filler) {
|
|
904
|
-
var ixs, iys, izs, x, y, z;
|
|
905
|
-
return _regenerator["default"].wrap(function izipLongest3$(_context13) {
|
|
906
|
-
while (1) {
|
|
907
|
-
switch (_context13.prev = _context13.next) {
|
|
908
|
-
case 0:
|
|
909
|
-
ixs = (0, _builtins.iter)(xs);
|
|
910
|
-
iys = (0, _builtins.iter)(ys);
|
|
911
|
-
izs = (0, _builtins.iter)(zs);
|
|
912
|
-
|
|
913
|
-
case 3:
|
|
914
|
-
x = ixs.next();
|
|
915
|
-
y = iys.next();
|
|
916
|
-
z = izs.next();
|
|
917
|
-
|
|
918
|
-
if (!(x.done && y.done && z.done)) {
|
|
919
|
-
_context13.next = 10;
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
return _context13.abrupt("return");
|
|
924
|
-
|
|
925
|
-
case 10:
|
|
926
|
-
_context13.next = 12;
|
|
927
|
-
return [!x.done ? x.value : filler, !y.done ? y.value : filler, !z.done ? z.value : filler];
|
|
928
|
-
|
|
929
|
-
case 12:
|
|
930
|
-
_context13.next = 3;
|
|
931
|
-
break;
|
|
932
|
-
|
|
933
|
-
case 14:
|
|
934
|
-
case "end":
|
|
935
|
-
return _context13.stop();
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}, _marked12);
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Like the other izips (`izip`, `izip3`, etc), but generalized to take an
|
|
942
|
-
* unlimited amount of input iterables. Think `izip(*iterables)` in Python.
|
|
943
|
-
*
|
|
944
|
-
* **Note:** Due to Flow type system limitations, you can only "generially" zip
|
|
945
|
-
* iterables with homogeneous types, so you cannot mix types like <A, B> like
|
|
946
|
-
* you can with izip2().
|
|
947
|
-
*/
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
function izipMany() {
|
|
951
|
-
var _len2,
|
|
952
|
-
iters,
|
|
953
|
-
_key2,
|
|
954
|
-
iterables,
|
|
955
|
-
heads,
|
|
956
|
-
_args14 = arguments;
|
|
957
|
-
|
|
958
|
-
return _regenerator["default"].wrap(function izipMany$(_context14) {
|
|
959
|
-
while (1) {
|
|
960
|
-
switch (_context14.prev = _context14.next) {
|
|
961
|
-
case 0:
|
|
962
|
-
for (_len2 = _args14.length, iters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
963
|
-
iters[_key2] = _args14[_key2];
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
// Make them all iterables
|
|
967
|
-
iterables = iters.map(_builtins.iter);
|
|
968
|
-
|
|
969
|
-
case 2:
|
|
970
|
-
heads = iterables.map(function (xs) {
|
|
971
|
-
return xs.next();
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
if (!(0, _builtins.all)(heads, function (h) {
|
|
975
|
-
return !h.done;
|
|
976
|
-
})) {
|
|
977
|
-
_context14.next = 8;
|
|
978
|
-
break;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
_context14.next = 6;
|
|
982
|
-
return heads.map(function (h) {
|
|
983
|
-
return h.value;
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
case 6:
|
|
987
|
-
_context14.next = 9;
|
|
988
|
-
break;
|
|
989
|
-
|
|
990
|
-
case 8:
|
|
991
|
-
return _context14.abrupt("return");
|
|
992
|
-
|
|
993
|
-
case 9:
|
|
994
|
-
_context14.next = 2;
|
|
995
|
-
break;
|
|
996
|
-
|
|
997
|
-
case 11:
|
|
998
|
-
case "end":
|
|
999
|
-
return _context14.stop();
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}, _marked13);
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Return successive `r`-length permutations of elements in the iterable.
|
|
1006
|
-
*
|
|
1007
|
-
* If `r` is not specified, then `r` defaults to the length of the iterable and
|
|
1008
|
-
* all possible full-length permutations are generated.
|
|
1009
|
-
*
|
|
1010
|
-
* Permutations are emitted in lexicographic sort order. So, if the input
|
|
1011
|
-
* iterable is sorted, the permutation tuples will be produced in sorted order.
|
|
1012
|
-
*
|
|
1013
|
-
* Elements are treated as unique based on their position, not on their value.
|
|
1014
|
-
* So if the input elements are unique, there will be no repeat values in each
|
|
1015
|
-
* permutation.
|
|
1016
|
-
*/
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
function permutations(iterable, r) {
|
|
1020
|
-
var pool, n, x, indices, cycles, poolgetter, cleanExit, _iterator9, _step10, i, j, _ref2, p, q;
|
|
1021
|
-
|
|
1022
|
-
return _regenerator["default"].wrap(function permutations$(_context15) {
|
|
1023
|
-
while (1) {
|
|
1024
|
-
switch (_context15.prev = _context15.next) {
|
|
1025
|
-
case 0:
|
|
1026
|
-
pool = Array.from(iterable);
|
|
1027
|
-
n = pool.length;
|
|
1028
|
-
x = r === undefined ? n : r;
|
|
1029
|
-
|
|
1030
|
-
if (!(x > n)) {
|
|
1031
|
-
_context15.next = 5;
|
|
1032
|
-
break;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
return _context15.abrupt("return");
|
|
1036
|
-
|
|
1037
|
-
case 5:
|
|
1038
|
-
indices = Array.from((0, _builtins.range)(n));
|
|
1039
|
-
cycles = Array.from((0, _builtins.range)(n, n - x, -1));
|
|
1040
|
-
|
|
1041
|
-
poolgetter = function poolgetter(i) {
|
|
1042
|
-
return pool[i];
|
|
1043
|
-
};
|
|
1044
|
-
|
|
1045
|
-
_context15.next = 10;
|
|
1046
|
-
return indices.slice(0, x).map(poolgetter);
|
|
1047
|
-
|
|
1048
|
-
case 10:
|
|
1049
|
-
if (!(n > 0)) {
|
|
1050
|
-
_context15.next = 45;
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
cleanExit = true;
|
|
1055
|
-
_iterator9 = _createForOfIteratorHelper((0, _builtins.range)(x - 1, -1, -1));
|
|
1056
|
-
_context15.prev = 13;
|
|
1057
|
-
|
|
1058
|
-
_iterator9.s();
|
|
1059
|
-
|
|
1060
|
-
case 15:
|
|
1061
|
-
if ((_step10 = _iterator9.n()).done) {
|
|
1062
|
-
_context15.next = 33;
|
|
1063
|
-
break;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
i = _step10.value;
|
|
1067
|
-
cycles[i] -= 1;
|
|
1068
|
-
|
|
1069
|
-
if (!(cycles[i] === 0)) {
|
|
1070
|
-
_context15.next = 23;
|
|
1071
|
-
break;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
indices = indices.slice(0, i).concat(indices.slice(i + 1)).concat(indices.slice(i, i + 1));
|
|
1075
|
-
cycles[i] = n - i;
|
|
1076
|
-
_context15.next = 31;
|
|
1077
|
-
break;
|
|
1078
|
-
|
|
1079
|
-
case 23:
|
|
1080
|
-
j = cycles[i];
|
|
1081
|
-
_ref2 = [indices[indices.length - j], indices[i]], p = _ref2[0], q = _ref2[1];
|
|
1082
|
-
indices[i] = p;
|
|
1083
|
-
indices[indices.length - j] = q;
|
|
1084
|
-
_context15.next = 29;
|
|
1085
|
-
return indices.slice(0, x).map(poolgetter);
|
|
1086
|
-
|
|
1087
|
-
case 29:
|
|
1088
|
-
cleanExit = false;
|
|
1089
|
-
return _context15.abrupt("break", 33);
|
|
1090
|
-
|
|
1091
|
-
case 31:
|
|
1092
|
-
_context15.next = 15;
|
|
1093
|
-
break;
|
|
1094
|
-
|
|
1095
|
-
case 33:
|
|
1096
|
-
_context15.next = 38;
|
|
1097
|
-
break;
|
|
1098
|
-
|
|
1099
|
-
case 35:
|
|
1100
|
-
_context15.prev = 35;
|
|
1101
|
-
_context15.t0 = _context15["catch"](13);
|
|
1102
|
-
|
|
1103
|
-
_iterator9.e(_context15.t0);
|
|
1104
|
-
|
|
1105
|
-
case 38:
|
|
1106
|
-
_context15.prev = 38;
|
|
1107
|
-
|
|
1108
|
-
_iterator9.f();
|
|
1109
|
-
|
|
1110
|
-
return _context15.finish(38);
|
|
1111
|
-
|
|
1112
|
-
case 41:
|
|
1113
|
-
if (!cleanExit) {
|
|
1114
|
-
_context15.next = 43;
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
return _context15.abrupt("return");
|
|
1119
|
-
|
|
1120
|
-
case 43:
|
|
1121
|
-
_context15.next = 10;
|
|
1122
|
-
break;
|
|
1123
|
-
|
|
1124
|
-
case 45:
|
|
1125
|
-
case "end":
|
|
1126
|
-
return _context15.stop();
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}, _marked14, null, [[13, 35, 38, 41]]);
|
|
1130
|
-
}
|
|
1131
|
-
/**
|
|
1132
|
-
* Returns an iterator that produces values over and over again. Runs
|
|
1133
|
-
* indefinitely unless the times argument is specified.
|
|
1134
|
-
*/
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
function repeat(thing, times) {
|
|
1138
|
-
var _iterator10, _step11, i;
|
|
1139
|
-
|
|
1140
|
-
return _regenerator["default"].wrap(function repeat$(_context16) {
|
|
1141
|
-
while (1) {
|
|
1142
|
-
switch (_context16.prev = _context16.next) {
|
|
1143
|
-
case 0:
|
|
1144
|
-
if (!(times === undefined)) {
|
|
1145
|
-
_context16.next = 7;
|
|
1146
|
-
break;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
case 1:
|
|
1150
|
-
_context16.next = 3;
|
|
1151
|
-
return thing;
|
|
1152
|
-
|
|
1153
|
-
case 3:
|
|
1154
|
-
_context16.next = 1;
|
|
1155
|
-
break;
|
|
1156
|
-
|
|
1157
|
-
case 5:
|
|
1158
|
-
_context16.next = 24;
|
|
1159
|
-
break;
|
|
1160
|
-
|
|
1161
|
-
case 7:
|
|
1162
|
-
// eslint-disable-next-line no-unused-vars
|
|
1163
|
-
_iterator10 = _createForOfIteratorHelper((0, _builtins.range)(times));
|
|
1164
|
-
_context16.prev = 8;
|
|
1165
|
-
|
|
1166
|
-
_iterator10.s();
|
|
1167
|
-
|
|
1168
|
-
case 10:
|
|
1169
|
-
if ((_step11 = _iterator10.n()).done) {
|
|
1170
|
-
_context16.next = 16;
|
|
1171
|
-
break;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
i = _step11.value;
|
|
1175
|
-
_context16.next = 14;
|
|
1176
|
-
return thing;
|
|
1177
|
-
|
|
1178
|
-
case 14:
|
|
1179
|
-
_context16.next = 10;
|
|
1180
|
-
break;
|
|
1181
|
-
|
|
1182
|
-
case 16:
|
|
1183
|
-
_context16.next = 21;
|
|
1184
|
-
break;
|
|
1185
|
-
|
|
1186
|
-
case 18:
|
|
1187
|
-
_context16.prev = 18;
|
|
1188
|
-
_context16.t0 = _context16["catch"](8);
|
|
1189
|
-
|
|
1190
|
-
_iterator10.e(_context16.t0);
|
|
1191
|
-
|
|
1192
|
-
case 21:
|
|
1193
|
-
_context16.prev = 21;
|
|
1194
|
-
|
|
1195
|
-
_iterator10.f();
|
|
1196
|
-
|
|
1197
|
-
return _context16.finish(21);
|
|
1198
|
-
|
|
1199
|
-
case 24:
|
|
1200
|
-
case "end":
|
|
1201
|
-
return _context16.stop();
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
}, _marked15, null, [[8, 18, 21, 24]]);
|
|
1205
|
-
}
|
|
1206
|
-
/**
|
|
1207
|
-
* Returns an iterator that produces elements from the iterable as long as the
|
|
1208
|
-
* predicate is true.
|
|
1209
|
-
*/
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
function takewhile(iterable, predicate) {
|
|
1213
|
-
var _iterator11, _step12, value;
|
|
1214
|
-
|
|
1215
|
-
return _regenerator["default"].wrap(function takewhile$(_context17) {
|
|
1216
|
-
while (1) {
|
|
1217
|
-
switch (_context17.prev = _context17.next) {
|
|
1218
|
-
case 0:
|
|
1219
|
-
_iterator11 = _createForOfIteratorHelper(iterable);
|
|
1220
|
-
_context17.prev = 1;
|
|
1221
|
-
|
|
1222
|
-
_iterator11.s();
|
|
1223
|
-
|
|
1224
|
-
case 3:
|
|
1225
|
-
if ((_step12 = _iterator11.n()).done) {
|
|
1226
|
-
_context17.next = 11;
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
value = _step12.value;
|
|
1231
|
-
|
|
1232
|
-
if (predicate(value)) {
|
|
1233
|
-
_context17.next = 7;
|
|
1234
|
-
break;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
return _context17.abrupt("return");
|
|
1238
|
-
|
|
1239
|
-
case 7:
|
|
1240
|
-
_context17.next = 9;
|
|
1241
|
-
return value;
|
|
1242
|
-
|
|
1243
|
-
case 9:
|
|
1244
|
-
_context17.next = 3;
|
|
1245
|
-
break;
|
|
1246
|
-
|
|
1247
|
-
case 11:
|
|
1248
|
-
_context17.next = 16;
|
|
1249
|
-
break;
|
|
1250
|
-
|
|
1251
|
-
case 13:
|
|
1252
|
-
_context17.prev = 13;
|
|
1253
|
-
_context17.t0 = _context17["catch"](1);
|
|
1254
|
-
|
|
1255
|
-
_iterator11.e(_context17.t0);
|
|
1256
|
-
|
|
1257
|
-
case 16:
|
|
1258
|
-
_context17.prev = 16;
|
|
1259
|
-
|
|
1260
|
-
_iterator11.f();
|
|
1261
|
-
|
|
1262
|
-
return _context17.finish(16);
|
|
1263
|
-
|
|
1264
|
-
case 19:
|
|
1265
|
-
case "end":
|
|
1266
|
-
return _context17.stop();
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
}, _marked16, null, [[1, 13, 16, 19]]);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
function zipLongest2(xs, ys, filler) {
|
|
1273
|
-
return Array.from(izipLongest2(xs, ys, filler));
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
function zipLongest3(xs, ys, zs, filler) {
|
|
1277
|
-
return Array.from(izipLongest3(xs, ys, zs, filler));
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
var izipLongest = izipLongest2;
|
|
1281
|
-
exports.izipLongest = izipLongest;
|
|
1282
|
-
var zipLongest = zipLongest2;
|
|
1283
|
-
exports.zipLongest = zipLongest;
|
|
1284
|
-
|
|
1285
|
-
function zipMany() {
|
|
1286
|
-
return Array.from(izipMany.apply(void 0, arguments));
|
|
1287
|
-
}
|