1 | /**
|
2 | * Copyright (c) 2013-present, Facebook, Inc.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | *
|
8 | */
|
9 |
|
10 | ;
|
11 |
|
12 | /* global Symbol */
|
13 |
|
14 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
15 | var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
16 |
|
17 | /**
|
18 | * Returns the iterator method function contained on the iterable object.
|
19 | *
|
20 | * Be sure to invoke the function with the iterable as context:
|
21 | *
|
22 | * var iteratorFn = getIteratorFn(myIterable);
|
23 | * if (iteratorFn) {
|
24 | * var iterator = iteratorFn.call(myIterable);
|
25 | * ...
|
26 | * }
|
27 | *
|
28 | * @param {?object} maybeIterable
|
29 | * @return {?function}
|
30 | */
|
31 | function getIteratorFn(maybeIterable) {
|
32 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
33 | if (typeof iteratorFn === 'function') {
|
34 | return iteratorFn;
|
35 | }
|
36 | }
|
37 |
|
38 | module.exports = getIteratorFn; |
\ | No newline at end of file |