aAdd getIterator and isIterable to babel-runtime build script - fixes #1243

This commit is contained in:
Sebastian McKenzie
2015-04-13 00:48:19 -07:00
parent 71eafdcac7
commit a505e4a121
4 changed files with 14 additions and 4 deletions

View File

@@ -42,7 +42,7 @@ var astVisitor = {
prop = callee.property;
if (!isSymbolIterator(prop)) return false;
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterator`, "getIterator", true), [callee.object]);
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterable`, "getIterator", true), [callee.object]);
} else if (this.isBinaryExpression()) {
// Symbol.iterator in arr -> core.$for.isIterable(arr)

View File

@@ -713,6 +713,11 @@ export default class TraversalPath {
var search = [this.node];
var i = 0;
function matches(name) {
var part = parts[i];
return part === "*" || name === part;
}
while (search.length) {
var node = search.shift();
@@ -722,10 +727,10 @@ export default class TraversalPath {
if (t.isIdentifier(node)) {
// this part doesn't match
if (parts[i] !== node.name) return false;
if (!matches(node.name)) return false;
} else if (t.isLiteral(node)) {
// this part doesn't match
if (parts[i] !== node.value) return false;
if (!matches(node.value)) return false;
} else if (t.isMemberExpression(node)) {
if (node.computed && !t.isLiteral(node.property)) {
// we can't deal with this