UNPKG

750 BJavaScriptView Raw
1/** @license MIT License (c) copyright 2010-2016 original author or authors */
2/** @author Brian Cavalier */
3/** @author John Hann */
4
5/*global Set, Symbol*/
6var iteratorSymbol
7// Firefox ships a partial implementation using the name @@iterator.
8// https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
9if (typeof Set === 'function' && typeof new Set()['@@iterator'] === 'function') {
10 iteratorSymbol = '@@iterator'
11} else {
12 iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator ||
13 '_es6shim_iterator_'
14}
15
16export function isIterable (o) {
17 return typeof o[iteratorSymbol] === 'function'
18}
19
20export function getIterator (o) {
21 return o[iteratorSymbol]()
22}
23
24export function makeIterable (f, o) {
25 o[iteratorSymbol] = f
26 return o
27}