34 lines
915 B
JavaScript
34 lines
915 B
JavaScript
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.isIterable = isIterable;
|
||
|
exports.getIterator = getIterator;
|
||
|
exports.makeIterable = makeIterable;
|
||
|
/** @license MIT License (c) copyright 2010-2016 original author or authors */
|
||
|
/** @author Brian Cavalier */
|
||
|
/** @author John Hann */
|
||
|
|
||
|
/* global Set, Symbol */
|
||
|
var iteratorSymbol;
|
||
|
// Firefox ships a partial implementation using the name @@iterator.
|
||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
|
||
|
if (typeof Set === 'function' && typeof new Set()['@@iterator'] === 'function') {
|
||
|
iteratorSymbol = '@@iterator';
|
||
|
} else {
|
||
|
iteratorSymbol = typeof Symbol === 'function' ? Symbol.iterator : '_es6shim_iterator_';
|
||
|
}
|
||
|
|
||
|
function isIterable(o) {
|
||
|
return typeof o[iteratorSymbol] === 'function';
|
||
|
}
|
||
|
|
||
|
function getIterator(o) {
|
||
|
return o[iteratorSymbol]();
|
||
|
}
|
||
|
|
||
|
function makeIterable(f, o) {
|
||
|
o[iteratorSymbol] = f;
|
||
|
return o;
|
||
|
}
|