Socket
Socket
Sign inDemoInstall

@babel/helper-define-map

Package Overview
Dependencies
Maintainers
6
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-define-map - npm Package Compare versions

Comparing version 7.14.5 to 7.15.4

65

lib/index.js

@@ -14,6 +14,25 @@ "use strict";

var t = require("@babel/types");
var _t = require("@babel/types");
const {
arrayExpression,
booleanLiteral,
functionExpression,
identifier,
inheritsComments,
isClassMethod,
isFunctionExpression,
isObjectMethod,
isObjectProperty,
isProperty,
isStringLiteral,
objectExpression,
objectProperty,
removeComments,
toComputedKey,
toKeyAlias
} = _t;
function toKind(node) {
if (t.isClassMethod(node) || t.isObjectMethod(node)) {
if (isClassMethod(node) || isObjectMethod(node)) {
if (node.kind === "get" || node.kind === "set") {

@@ -30,3 +49,3 @@ return node.kind;

function push(mutatorMap, node, kind, file, scope) {
const alias = t.toKeyAlias(node);
const alias = toKeyAlias(node);
let map = {};

@@ -46,4 +65,4 @@ if (has(mutatorMap, alias)) map = mutatorMap[alias];

if (node.decorators) {
const decorators = map.decorators = map.decorators || t.arrayExpression([]);
decorators.elements = decorators.elements.concat(node.decorators.map(dec => dec.expression).reverse());
const decorators = map.decorators = map.decorators || arrayExpression([]);
decorators.elements.push(...node.decorators.map(dec => dec.expression).reverse());
}

@@ -57,10 +76,10 @@

if (t.isObjectProperty(node) || t.isObjectMethod(node) || t.isClassMethod(node)) {
key = t.toComputedKey(node, node.key);
if (isObjectProperty(node) || isObjectMethod(node) || isClassMethod(node)) {
key = toComputedKey(node, node.key);
}
if (t.isProperty(node)) {
if (isProperty(node)) {
value = node.value;
} else if (t.isObjectMethod(node) || t.isClassMethod(node)) {
value = t.functionExpression(null, node.params, node.body, node.generator, node.async);
} else if (isObjectMethod(node) || isClassMethod(node)) {
value = functionExpression(null, node.params, node.body, node.generator, node.async);
value.returnType = node.returnType;

@@ -75,3 +94,3 @@ }

if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && t.isFunctionExpression(value)) {
if (scope && isStringLiteral(key) && (kind === "value" || kind === "initializer") && isFunctionExpression(value)) {
value = (0, _helperFunctionName.default)({

@@ -85,3 +104,3 @@ id: key,

if (value) {
t.inheritsComments(value, node);
inheritsComments(value, node);
map[kind] = value;

@@ -104,3 +123,3 @@ }

function toComputedObjectFromClass(obj) {
const objExpr = t.arrayExpression([]);
const objExpr = arrayExpression([]);

@@ -110,3 +129,3 @@ for (let i = 0; i < obj.properties.length; i++) {

const val = prop.value;
val.properties.unshift(t.objectProperty(t.identifier("key"), t.toComputedKey(prop)));
val.properties.unshift(objectProperty(identifier("key"), toComputedKey(prop)));
objExpr.elements.push(val);

@@ -119,13 +138,13 @@ }

function toClassObject(mutatorMap) {
const objExpr = t.objectExpression([]);
const objExpr = objectExpression([]);
Object.keys(mutatorMap).forEach(function (mutatorMapKey) {
const map = mutatorMap[mutatorMapKey];
const mapNode = t.objectExpression([]);
const propNode = t.objectProperty(map._key, mapNode, map._computed);
const mapNode = objectExpression([]);
const propNode = objectProperty(map._key, mapNode, map._computed);
Object.keys(map).forEach(function (key) {
const node = map[key];
if (key[0] === "_") return;
const prop = t.objectProperty(t.identifier(key), node);
t.inheritsComments(prop, node);
t.removeComments(node);
const prop = objectProperty(identifier(key), node);
inheritsComments(prop, node);
removeComments(node);
mapNode.properties.push(prop);

@@ -141,7 +160,7 @@ });

const map = mutatorMap[key];
if (map.value) map.writable = t.booleanLiteral(true);
map.configurable = t.booleanLiteral(true);
map.enumerable = t.booleanLiteral(true);
if (map.value) map.writable = booleanLiteral(true);
map.configurable = booleanLiteral(true);
map.enumerable = booleanLiteral(true);
});
return toClassObject(mutatorMap);
}
{
"name": "@babel/helper-define-map",
"version": "7.14.5",
"version": "7.15.4",
"description": "Helper function to define a map",

@@ -17,4 +17,4 @@ "repository": {

"dependencies": {
"@babel/helper-function-name": "^7.14.5",
"@babel/types": "^7.14.5"
"@babel/helper-function-name": "^7.15.4",
"@babel/types": "^7.15.4"
},

@@ -21,0 +21,0 @@ "engines": {

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