1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function isIterator(candidate) {
|
4 | return typeof candidate === 'object' && candidate !== null && typeof candidate.next === 'function';
|
5 | }
|
6 | exports.isIterator = isIterator;
|
7 | function isIterable(candidate) {
|
8 | return typeof candidate === 'object' && candidate !== null && typeof candidate[Symbol.iterator] === 'function';
|
9 | }
|
10 | exports.isIterable = isIterable;
|
11 | function toIterator(collection) {
|
12 | if (isIterator(collection)) {
|
13 | return collection;
|
14 | }
|
15 | if (isIterable(collection)) {
|
16 | return collection[Symbol.iterator]();
|
17 | }
|
18 | throw new Error('Passed collection is neither an Iterator nor an Iterable');
|
19 | }
|
20 | exports.toIterator = toIterator;
|
21 |
|
\ | No newline at end of file |