New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-es5-array-autopolyfill

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-es5-array-autopolyfill - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

test/fixtures/convert-chain-calls/.babelrc

51

lib/index.js

@@ -34,23 +34,31 @@ 'use strict';

CallExpression: function CallExpression(path) {
var property = path.get('callee.property').node;
if (!t.isIdentifier(property) || replaceProperties.indexOf(property.name) < 0) {
return;
}
CallExpression: {
exit: function exit(path) {
var annotation;
var property = path.get('callee.property').node;
if (!isObjectCaller(t, property)) {
return;
}
var identifierPath = path.get("callee.object", true);
var identifierPath = path.get("callee.object", true);
if (!identifierPath.isNodeType("Identifier") && !identifierPath.isNodeType("TypeCastExpression")) {
return;
}
if (!identifierPath.isNodeType("Identifier") && !identifierPath.isNodeType("TypeCastExpression")) {
return;
}
annotation = identifierPath.getTypeAnnotation();
var annotation = identifierPath.getTypeAnnotation();
if (!isArrayType(t, annotation)) {
return;
if (!isArrayType(t, annotation)) {
return;
}
var oldName = property.name;
property.name = prefix + property.name;
var callee = path.node.callee;
var expression = t.callExpression(property, [callee.object].concat(path.node.arguments));
usedMethods[oldName] = true;
if (arrayReturn.indexOf(oldName) >= 0) {
path.replaceWith(t.typeCastExpression(expression, t.arrayTypeAnnotation('Any')));
} else {
path.replaceWith(expression);
}
}
var callee = path.node.callee;
usedMethods[property.name] = true;
property.name = prefix + property.name;
path.replaceWith(t.callExpression(property, [callee.object].concat(path.node.arguments)));
}

@@ -62,2 +70,3 @@ }

var replaceProperties = ['reduce', 'map', 'filter', 'forEach'];
var arrayReturn = ['map', 'filter'];
var prefix = "es5";

@@ -75,2 +84,10 @@

return false;
}
function isObjectCaller(t, property) {
return t.isIdentifier(property) && property && replaceProperties.indexOf(property.name) >= 0;
}
function isFunctionTypeCastCaller(t, path, prop) {
return t.isTypeCastExpression(path.parentPath.node) && !prop;
}
{
"name": "babel-plugin-es5-array-autopolyfill",
"version": "3.0.1",
"version": "3.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -14,3 +14,2 @@ import path from 'path';

fs.readdirSync(fixturesDir).map((caseName) => {
it(`should ${caseName.split('-').join(' ')}`, () => {

@@ -17,0 +16,0 @@ const fixtureDir = path.join(fixturesDir, caseName);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc