* 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
6 lines
292 B
JavaScript
6 lines
292 B
JavaScript
import _Array$from from "../../core-js/array/from";
|
|
import _isIterable from "../../core-js/is-iterable";
|
|
import _Symbol from "../../core-js/symbol";
|
|
export default function _iterableToArray(iter) {
|
|
if (typeof _Symbol !== "undefined" && _isIterable(Object(iter))) return _Array$from(iter);
|
|
} |