You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@babel/types

Package Overview
Dependencies
3
Maintainers
5
Versions
162
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.3.4 to 7.4.0

lib/definitions/placeholders.js

16

lib/asserts/generated/index.js

@@ -45,2 +45,3 @@ "use strict";

exports.assertSequenceExpression = assertSequenceExpression;
exports.assertParenthesizedExpression = assertParenthesizedExpression;
exports.assertSwitchCase = assertSwitchCase;

@@ -150,3 +151,4 @@ exports.assertSwitchStatement = assertSwitchStatement;

exports.assertNoop = assertNoop;
exports.assertParenthesizedExpression = assertParenthesizedExpression;
exports.assertPlaceholder = assertPlaceholder;
exports.assertArgumentPlaceholder = assertArgumentPlaceholder;
exports.assertAwaitExpression = assertAwaitExpression;

@@ -442,2 +444,6 @@ exports.assertBindExpression = assertBindExpression;

function assertParenthesizedExpression(node, opts = {}) {
assert("ParenthesizedExpression", node, opts);
}
function assertSwitchCase(node, opts = {}) {

@@ -859,6 +865,10 @@ assert("SwitchCase", node, opts);

function assertParenthesizedExpression(node, opts = {}) {
assert("ParenthesizedExpression", node, opts);
function assertPlaceholder(node, opts = {}) {
assert("Placeholder", node, opts);
}
function assertArgumentPlaceholder(node, opts = {}) {
assert("ArgumentPlaceholder", node, opts);
}
function assertAwaitExpression(node, opts = {}) {

@@ -865,0 +875,0 @@ assert("AwaitExpression", node, opts);

2

lib/builders/builder.js

@@ -45,3 +45,3 @@ "use strict";

for (const key in node) {
for (const key of Object.keys(node)) {
(0, _validate.default)(node, key, node[key]);

@@ -48,0 +48,0 @@ }

@@ -45,2 +45,3 @@ "use strict";

exports.sequenceExpression = exports.SequenceExpression = SequenceExpression;
exports.parenthesizedExpression = exports.ParenthesizedExpression = ParenthesizedExpression;
exports.switchCase = exports.SwitchCase = SwitchCase;

@@ -150,3 +151,4 @@ exports.switchStatement = exports.SwitchStatement = SwitchStatement;

exports.noop = exports.Noop = Noop;
exports.parenthesizedExpression = exports.ParenthesizedExpression = ParenthesizedExpression;
exports.placeholder = exports.Placeholder = Placeholder;
exports.argumentPlaceholder = exports.ArgumentPlaceholder = ArgumentPlaceholder;
exports.awaitExpression = exports.AwaitExpression = AwaitExpression;

@@ -394,2 +396,6 @@ exports.bindExpression = exports.BindExpression = BindExpression;

function ParenthesizedExpression(...args) {
return (0, _builder.default)("ParenthesizedExpression", ...args);
}
function SwitchCase(...args) {

@@ -811,6 +817,10 @@ return (0, _builder.default)("SwitchCase", ...args);

function ParenthesizedExpression(...args) {
return (0, _builder.default)("ParenthesizedExpression", ...args);
function Placeholder(...args) {
return (0, _builder.default)("Placeholder", ...args);
}
function ArgumentPlaceholder(...args) {
return (0, _builder.default)("ArgumentPlaceholder", ...args);
}
function AwaitExpression(...args) {

@@ -817,0 +827,0 @@ return (0, _builder.default)("AwaitExpression", ...args);

@@ -35,3 +35,3 @@ "use strict";

for (const key in bindings) {
for (const key of Object.keys(bindings)) {
declars.push({

@@ -38,0 +38,0 @@ kind: node.kind,

@@ -88,3 +88,3 @@ "use strict";

for (const key in value) {
for (const key of Object.keys(value)) {
let nodeKey;

@@ -91,0 +91,0 @@

@@ -117,3 +117,3 @@ "use strict";

arguments: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName")))
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
},

@@ -576,2 +576,11 @@ optional: {

});
(0, _utils.default)("ParenthesizedExpression", {
visitor: ["expression"],
aliases: ["Expression", "ExpressionWrapper"],
fields: {
expression: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("SwitchCase", {

@@ -578,0 +587,0 @@ visitor: ["test", "consequent"],

@@ -9,2 +9,3 @@ "use strict";

(0, _utils.default)("ArgumentPlaceholder", {});
(0, _utils.default)("AwaitExpression", {

@@ -11,0 +12,0 @@ builder: ["argument"],

@@ -42,2 +42,20 @@ "use strict";

});
Object.defineProperty(exports, "PLACEHOLDERS", {
enumerable: true,
get: function () {
return _placeholders.PLACEHOLDERS;
}
});
Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", {
enumerable: true,
get: function () {
return _placeholders.PLACEHOLDERS_ALIAS;
}
});
Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", {
enumerable: true,
get: function () {
return _placeholders.PLACEHOLDERS_FLIPPED_ALIAS;
}
});
exports.TYPES = void 0;

@@ -71,2 +89,4 @@

var _placeholders = require("./placeholders");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -80,3 +100,5 @@

(0, _toFastProperties().default)(_utils.DEPRECATED_KEYS);
(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_ALIAS);
(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS);
const TYPES = Object.keys(_utils.VISITOR_KEYS).concat(Object.keys(_utils.FLIPPED_ALIAS_KEYS)).concat(Object.keys(_utils.DEPRECATED_KEYS));
exports.TYPES = TYPES;

@@ -5,2 +5,4 @@ "use strict";

var _placeholders = require("./placeholders");
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; } }

@@ -11,10 +13,13 @@

});
(0, _utils.default)("ParenthesizedExpression", {
visitor: ["expression"],
aliases: ["Expression", "ExpressionWrapper"],
(0, _utils.default)("Placeholder", {
visitor: [],
builder: ["expectedNode", "name"],
fields: {
expression: {
validate: (0, _utils.assertNodeType)("Expression")
name: {
validate: (0, _utils.assertNodeType)("Identifier")
},
expectedNode: {
validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS)
}
}
});

@@ -113,3 +113,3 @@ "use strict";

aliases: ["TSType"],
visitor: ["typeParameters", "typeAnnotation"],
visitor: ["typeParameters", "parameters", "typeAnnotation"],
fields: signatureDeclarationCommon

@@ -116,0 +116,0 @@ };

@@ -195,3 +195,3 @@ "use strict";

for (const key in fields) {
for (const key of Object.keys(fields)) {
const field = fields[key];

@@ -198,0 +198,0 @@

@@ -50,2 +50,3 @@ "use strict";

isNodesEquivalent: true,
isPlaceholderType: true,
isReferenced: true,

@@ -314,2 +315,8 @@ isScope: true,

});
Object.defineProperty(exports, "isPlaceholderType", {
enumerable: true,
get: function () {
return _isPlaceholderType.default;
}
});
Object.defineProperty(exports, "isReferenced", {

@@ -532,2 +539,4 @@ enumerable: true,

var _isPlaceholderType = _interopRequireDefault(require("./validators/isPlaceholderType"));
var _isReferenced = _interopRequireDefault(require("./validators/isReferenced"));

@@ -534,0 +543,0 @@

@@ -65,7 +65,7 @@ "use strict";

for (const type in bases) {
for (const type of Object.keys(bases)) {
types.push(bases[type]);
}
for (const name in generics) {
for (const name of Object.keys(generics)) {
types.push(generics[name]);

@@ -72,0 +72,0 @@ }

@@ -23,3 +23,3 @@ "use strict";

for (const key in parent) {
for (const key of Object.keys(parent)) {
if (key[0] === "_" && key !== "__clone") child[key] = parent[key];

@@ -26,0 +26,0 @@ }

@@ -21,3 +21,3 @@ "use strict";

for (const key in node) {
for (const key of Object.keys(node)) {
if (key[0] === "_" && node[key] != null) node[key] = undefined;

@@ -24,0 +24,0 @@ }

@@ -12,2 +12,6 @@ "use strict";

var _isPlaceholderType = _interopRequireDefault(require("./isPlaceholderType"));
var _definitions = require("../definitions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -18,4 +22,11 @@

const matches = (0, _isType.default)(node.type, type);
if (!matches) return false;
if (!matches) {
if (!opts && node.type === "Placeholder" && type in _definitions.FLIPPED_ALIAS_KEYS) {
return (0, _isPlaceholderType.default)(node.expectedNode, type);
}
return false;
}
if (typeof opts === "undefined") {

@@ -22,0 +33,0 @@ return true;

@@ -12,3 +12,7 @@ "use strict";

function isBinding(node, parent) {
function isBinding(node, parent, grandparent) {
if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") {
return false;
}
const keys = _getBindingIdentifiers.default.keys[parent.type];

@@ -15,0 +19,0 @@

@@ -27,2 +27,8 @@ "use strict";

if (a[field] == null && b[field] == null) {
continue;
} else if (a[field] == null || b[field] == null) {
return false;
}
if (Array.isArray(a[field])) {

@@ -47,3 +53,3 @@ if (!Array.isArray(b[field])) {

if (typeof a[field] === "object" && (!visitorKeys || !visitorKeys.includes(field))) {
for (const key in a[field]) {
for (const key of Object.keys(a[field])) {
if (a[field][key] !== b[field][key]) {

@@ -50,0 +56,0 @@ return false;

@@ -8,3 +8,3 @@ "use strict";

function isReferenced(node, parent) {
function isReferenced(node, parent, grandparent) {
switch (parent.type) {

@@ -43,4 +43,8 @@ case "MemberExpression":

return parent.value === node;
if (parent.value === node) {
return !grandparent || grandparent.type !== "ObjectPattern";
}
return true;
case "ClassDeclaration":

@@ -94,2 +98,12 @@ case "ClassExpression":

return parent.key !== node;
case "TSEnumMember":
return parent.id !== node;
case "TSPropertySignature":
if (parent.key === node) {
return !!parent.computed;
}
return true;
}

@@ -96,0 +110,0 @@

{
"name": "@babel/types",
"version": "7.3.4",
"version": "7.4.0",
"description": "Babel Types is a Lodash-esque utility library for AST nodes",

@@ -17,6 +17,6 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"devDependencies": {
"@babel/generator": "^7.3.4",
"@babel/parser": "^7.3.4"
"@babel/generator": "^7.4.0",
"@babel/parser": "^7.4.0"
},
"gitHead": "1f6454cc90fe33e0a32260871212e2f719f35741"
"gitHead": "f1328fb913b5a93d54dfc6e3728b1f56c8f4a804"
}
"use strict";
const fs = require("fs");
const path = require("path");

@@ -9,32 +8,23 @@ const chalk = require("chalk");

const generateConstants = require("./generators/generateConstants");
const format = require("./utils/formatCode");
const format = require("../../../scripts/utils/formatCode");
const writeFile = require("../../../scripts/utils/writeFileAndMkDir");
const baseDir = path.join(__dirname, "../src");
function writeFile(content, location) {
const file = path.join(baseDir, location);
try {
fs.mkdirSync(path.dirname(file));
} catch (error) {
if (error.code !== "EEXIST") {
throw error;
}
}
fs.writeFileSync(file, format(content, file));
}
console.log("Generating @babel/types dynamic functions");
writeFile(generateBuilders(), "builders/generated/index.js");
const buildersFile = path.join(baseDir, "builders/generated/index.js");
writeFile(buildersFile, format(generateBuilders(), buildersFile));
console.log(` ${chalk.green("✔")} Generated builders`);
writeFile(generateValidators(), "validators/generated/index.js");
const validatorsFile = path.join(baseDir, "validators/generated/index.js");
writeFile(validatorsFile, format(generateValidators(), validatorsFile));
console.log(` ${chalk.green("✔")} Generated validators`);
writeFile(generateAsserts(), "asserts/generated/index.js");
const assertsFile = path.join(baseDir, "asserts/generated/index.js");
writeFile(assertsFile, format(generateAsserts(), assertsFile));
console.log(` ${chalk.green("✔")} Generated asserts`);
writeFile(generateConstants(), "constants/generated/index.js");
const constantsFile = path.join(baseDir, "constants/generated/index.js");
writeFile(constantsFile, format(generateConstants(), constantsFile));
console.log(` ${chalk.green("✔")} Generated constants`);
"use strict";
const definitions = require("../../lib/definitions");
const has = Function.call.bind(Object.prototype.hasOwnProperty);
function joinComparisons(leftArr, right) {
return (
leftArr.map(JSON.stringify).join(` === ${right} || `) + ` === ${right}`
);
}
function addIsHelper(type, aliasKeys, deprecated) {

@@ -8,8 +16,23 @@ const targetType = JSON.stringify(type);

if (aliasKeys) {
aliasSource =
" || " +
aliasKeys.map(JSON.stringify).join(" === nodeType || ") +
" === nodeType";
aliasSource = " || " + joinComparisons(aliasKeys, "nodeType");
}
let placeholderSource = "";
const placeholderTypes = [];
if (
definitions.PLACEHOLDERS.includes(type) &&
has(definitions.FLIPPED_ALIAS_KEYS, type)
) {
placeholderTypes.push(type);
}
if (has(definitions.PLACEHOLDERS_FLIPPED_ALIAS, type)) {
placeholderTypes.push(...definitions.PLACEHOLDERS_FLIPPED_ALIAS[type]);
}
if (placeholderTypes.length > 0) {
placeholderSource =
' || nodeType === "Placeholder" && (' +
joinComparisons(placeholderTypes, "node.expectedNode") +
")";
}
return `export function is${type}(node: ?Object, opts?: Object): boolean {

@@ -20,3 +43,3 @@ ${deprecated || ""}

const nodeType = node.type;
if (nodeType === ${targetType}${aliasSource}) {
if (nodeType === ${targetType}${aliasSource}${placeholderSource}) {
if (typeof opts === "undefined") {

@@ -23,0 +46,0 @@ return true;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc