UNPKG

769 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function isIterator(candidate) {
4 return typeof candidate === 'object' && candidate !== null && typeof candidate.next === 'function';
5}
6exports.isIterator = isIterator;
7function isIterable(candidate) {
8 return typeof candidate === 'object' && candidate !== null && typeof candidate[Symbol.iterator] === 'function';
9}
10exports.isIterable = isIterable;
11function 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}
20exports.toIterator = toIterator;
21//# sourceMappingURL=utils.js.map
\No newline at end of file