fix(rest-spread): Do not require Symbol.iterator for strings (#9794)
This commit is contained in:
parent
661ffbd830
commit
7b9bc7c28b
@ -934,8 +934,9 @@ helpers.arrayWithHoles = helper("7.0.0-beta.0")`
|
|||||||
helpers.iterableToArray = helper("7.0.0-beta.0")`
|
helpers.iterableToArray = helper("7.0.0-beta.0")`
|
||||||
export default function _iterableToArray(iter) {
|
export default function _iterableToArray(iter) {
|
||||||
if (
|
if (
|
||||||
Symbol.iterator in Object(iter) ||
|
typeof iter === 'string'
|
||||||
Object.prototype.toString.call(iter) === "[object Arguments]"
|
|| Object.prototype.toString.call(iter) === "[object Arguments]"
|
||||||
|
|| Symbol.iterator in Object(iter)
|
||||||
) return Array.from(iter);
|
) return Array.from(iter);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
function sum(x, y, z) {
|
||||||
|
return x + y + z;
|
||||||
|
}
|
||||||
|
function test() {
|
||||||
|
var args = arguments;
|
||||||
|
return sum(...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(test(1, 2, 3)).toBe(6);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["proposal-object-rest-spread"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
expect([...'']).toHaveLength(0);
|
||||||
|
expect([...'abc']).toHaveLength(3);
|
||||||
|
expect([...'def']).toMatchObject(['d','e','f']);
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import _Array$from from "../../core-js/array/from";
|
import _Array$from from "../../core-js/array/from";
|
||||||
import _isIterable from "../../core-js/is-iterable";
|
import _isIterable from "../../core-js/is-iterable";
|
||||||
export default function _iterableToArray(iter) {
|
export default function _iterableToArray(iter) {
|
||||||
if (_isIterable(Object(iter)) || Object.prototype.toString.call(iter) === "[object Arguments]") return _Array$from(iter);
|
if (typeof iter === 'string' || Object.prototype.toString.call(iter) === "[object Arguments]" || _isIterable(Object(iter))) return _Array$from(iter);
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ var _Array$from = require("../core-js/array/from");
|
|||||||
var _isIterable = require("../core-js/is-iterable");
|
var _isIterable = require("../core-js/is-iterable");
|
||||||
|
|
||||||
function _iterableToArray(iter) {
|
function _iterableToArray(iter) {
|
||||||
if (_isIterable(Object(iter)) || Object.prototype.toString.call(iter) === "[object Arguments]") return _Array$from(iter);
|
if (typeof iter === 'string' || Object.prototype.toString.call(iter) === "[object Arguments]" || _isIterable(Object(iter))) return _Array$from(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = _iterableToArray;
|
module.exports = _iterableToArray;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
export default function _iterableToArray(iter) {
|
export default function _iterableToArray(iter) {
|
||||||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
if (typeof iter === 'string' || Object.prototype.toString.call(iter) === "[object Arguments]" || Symbol.iterator in Object(iter)) return Array.from(iter);
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
function _iterableToArray(iter) {
|
function _iterableToArray(iter) {
|
||||||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
if (typeof iter === 'string' || Object.prototype.toString.call(iter) === "[object Arguments]" || Symbol.iterator in Object(iter)) return Array.from(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = _iterableToArray;
|
module.exports = _iterableToArray;
|
||||||
Loading…
x
Reference in New Issue
Block a user