Socket
Socket
Sign inDemoInstall

@babel/helper-define-map

Package Overview
Dependencies
Maintainers
5
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.5.5 to 7.7.0

78

lib/index.js

@@ -12,38 +12,16 @@ "use strict";

function _helperFunctionName() {
const data = _interopRequireDefault(require("@babel/helper-function-name"));
var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name"));
_helperFunctionName = function () {
return data;
};
var _has = _interopRequireDefault(require("lodash/has"));
return data;
}
var t = _interopRequireWildcard(require("@babel/types"));
function _has() {
const data = _interopRequireDefault(require("lodash/has"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
_has = function () {
return data;
};
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function toKind(node) {
if (t().isClassMethod(node) || t().isObjectMethod(node)) {
if (t.isClassMethod(node) || t.isObjectMethod(node)) {
if (node.kind === "get" || node.kind === "set") {

@@ -58,5 +36,5 @@ return node.kind;

function push(mutatorMap, node, kind, file, scope) {
const alias = t().toKeyAlias(node);
const alias = t.toKeyAlias(node);
let map = {};
if ((0, _has().default)(mutatorMap, alias)) map = mutatorMap[alias];
if ((0, _has.default)(mutatorMap, alias)) map = mutatorMap[alias];
mutatorMap[alias] = map;

@@ -74,3 +52,3 @@ map._inherits = map._inherits || [];

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

@@ -85,10 +63,10 @@ }

if (t().isObjectProperty(node) || t().isObjectMethod(node) || t().isClassMethod(node)) {
key = t().toComputedKey(node, node.key);
if (t.isObjectProperty(node) || t.isObjectMethod(node) || t.isClassMethod(node)) {
key = t.toComputedKey(node, node.key);
}
if (t().isProperty(node)) {
if (t.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 (t.isObjectMethod(node) || t.isClassMethod(node)) {
value = t.functionExpression(null, node.params, node.body, node.generator, node.async);
value.returnType = node.returnType;

@@ -103,4 +81,4 @@ }

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

@@ -113,3 +91,3 @@ node: value,

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

@@ -132,3 +110,3 @@ }

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

@@ -138,3 +116,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(t.objectProperty(t.identifier("key"), t.toComputedKey(prop)));
objExpr.elements.push(val);

@@ -147,13 +125,13 @@ }

function toClassObject(mutatorMap) {
const objExpr = t().objectExpression([]);
const objExpr = t.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 = t.objectExpression([]);
const propNode = t.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 = t.objectProperty(t.identifier(key), node);
t.inheritsComments(prop, node);
t.removeComments(node);
mapNode.properties.push(prop);

@@ -169,7 +147,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 = t.booleanLiteral(true);
map.configurable = t.booleanLiteral(true);
map.enumerable = t.booleanLiteral(true);
});
return toClassObject(mutatorMap);
}
{
"name": "@babel/helper-define-map",
"version": "7.5.5",
"version": "7.7.0",
"description": "Helper function to define a map",

@@ -12,7 +12,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",

"dependencies": {
"@babel/helper-function-name": "^7.1.0",
"@babel/types": "^7.5.5",
"@babel/helper-function-name": "^7.7.0",
"@babel/types": "^7.7.0",
"lodash": "^4.17.13"
},
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43"
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
}
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