UNPKG

620 BJavaScriptView Raw
1'use strict';
2var call = require('../internals/function-call');
3var aCallable = require('../internals/a-callable');
4var anObject = require('../internals/an-object');
5var tryToString = require('../internals/try-to-string');
6var getIteratorMethod = require('../internals/get-iterator-method');
7
8var $TypeError = TypeError;
9
10module.exports = function (argument, usingIterator) {
11 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
12 if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
13 throw new $TypeError(tryToString(argument) + ' is not iterable');
14};