UNPKG

core-js

Version:
15 lines (12 loc) 632 B
'use strict'; var call = require('../internals/function-call'); var isCallable = require('../internals/is-callable'); var anObject = require('../internals/an-object'); var tryToString = require('../internals/try-to-string'); var getIteratorMethod = require('../internals/get-iterator-method-internal'); var $TypeError = TypeError; module.exports = function (argument, usingIterator) { var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; if (isCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); throw new $TypeError(tryToString(argument) + ' is not iterable'); };