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 1.0.0 to 2.0.0

test/fixtures/do-nothing-on-no-es5-function-calls/.babelrc

27

lib/index.js

@@ -10,4 +10,26 @@ 'use strict';

var usedMethods = {};
return {
visitor: {
Program: {
enter: function enter(path) {
var usedMethods = {};
},
exit: function exit(path, state) {
var libName = state.opts.polyfill;
var methods = Object.keys(usedMethods).sort();
if (methods.length === 0) {
return;
}
var specifiers = methods.map(function (el) {
return t.importSpecifier(t.identifier(prefix + el), t.identifier(el));
});
var importDecl = t.importDeclaration(specifiers, t.stringLiteral(libName));
path.node.body = [importDecl].concat(path.node.body);
}
},
CallExpression: function CallExpression(path) {

@@ -20,2 +42,4 @@ var callee = path.node.callee;

if (t.isIdentifier(property) && replaceProperties.indexOf(property.name) >= 0) {
usedMethods[property.name] = true;
property.name = prefix + property.name;
path.replaceWith(t.callExpression(property, [callee.object].concat(path.node.arguments)));

@@ -28,2 +52,3 @@ }

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

2

package.json
{
"name": "babel-plugin-es5-array-autopolyfill",
"version": "1.0.0",
"version": "2.0.0",
"description": "",

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

@@ -1,11 +0,12 @@

map(arr, el => el + 1);
map(arr, (el, i) => el + i);
import { filter as es5filter, forEach as es5forEach, map as es5map, reduce as es5reduce } from "es5-collection-methods";
es5map(arr, el => el + 1);
es5map(arr, (el, i) => el + i);
filter(arr, el => !el);
es5filter(arr, el => !el);
reduce(arr, (acc, el) => acc + el, {});
es5reduce(arr, (acc, el) => acc + el, {});
forEach(arr, el => t(el));
forEach(arr, (el, i) => t(el, i));
es5forEach(arr, el => t(el));
es5forEach(arr, (el, i) => t(el, i));
obj.somMethid(1, 2, 3);

Sorry, the diff of this file is not supported yet

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