* Allow rest/spread on polyfilled or builtin iterables when `Symbol` unsupported Currently, when `Symbol` is not supported, we allow using rest/spread with: - arrays - strings - arguments With this PR, it will be also possible to use it with - maps - sets - binary arrays While in old browsers es6 builtins would still need to be polyfilled, it's way easier to polyfill them because `Symbol` cannot be reliably polyfilled. I didn't use `instanceof` becase: - it doesn't work with polyfills not attatched to the global scope - when using Babel to load polyfills, it would force the inclusion of `Map` and `Set` polyfills even if they are not used Downside: the current approach of relying on `toString || construcor.name` doesn't work with subclasses. * Don't use Array.from for array-like objects
11 lines
316 B
JavaScript
11 lines
316 B
JavaScript
var _Array$from = require("../core-js/array/from");
|
|
|
|
var _isIterable = require("../core-js/is-iterable");
|
|
|
|
var _Symbol = require("../core-js/symbol");
|
|
|
|
function _iterableToArray(iter) {
|
|
if (typeof _Symbol !== "undefined" && _isIterable(Object(iter))) return _Array$from(iter);
|
|
}
|
|
|
|
module.exports = _iterableToArray; |