babel-plugin-es5-array-autopolyfill
Advanced tools
Comparing version 2.0.1 to 3.0.0
@@ -36,6 +36,14 @@ 'use strict'; | ||
var callee = path.node.callee; | ||
if (!t.isMemberExpression(callee)) { | ||
var identifierPath = path.get("callee.object", true); | ||
if (!identifierPath.isNodeType("Identifier") && !identifierPath.isNodeType("TypeCastExpression")) { | ||
return; | ||
} | ||
var property = callee.property; | ||
var annotation = identifierPath.getTypeAnnotation(); | ||
if (!isArrayType(t, annotation)) { | ||
return; | ||
} | ||
var property = path.get('callee.property').node; | ||
if (t.isIdentifier(property) && replaceProperties.indexOf(property.name) >= 0) { | ||
@@ -52,2 +60,14 @@ usedMethods[property.name] = true; | ||
var replaceProperties = ['reduce', 'map', 'filter', 'forEach']; | ||
var prefix = "es5"; | ||
var prefix = "es5"; | ||
function isArrayType(t, node) { | ||
if (t.isArrayTypeAnnotation(node)) { | ||
return true; | ||
} | ||
if (t.isGenericTypeAnnotation(node) && node.id.name === 'Array') { | ||
return true; | ||
} | ||
return false; | ||
} |
{ | ||
"name": "babel-plugin-es5-array-autopolyfill", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "", | ||
@@ -16,2 +16,4 @@ "main": "lib/index.js", | ||
"babel-eslint": "^4.1.6", | ||
"babel-plugin-syntax-flow": "^6.5.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.7.0", | ||
"babel-preset-es2015": "^6.1.18", | ||
@@ -18,0 +20,0 @@ "babel-register": "^6.2.0", |
@@ -14,2 +14,3 @@ import path from 'path'; | ||
fs.readdirSync(fixturesDir).map((caseName) => { | ||
it(`should ${caseName.split('-').join(' ')}`, () => { | ||
@@ -16,0 +17,0 @@ const fixtureDir = path.join(fixturesDir, caseName); |
Sorry, the diff of this file is not supported yet
6411
18
115
11