Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

recast

Package Overview
Dependencies
Maintainers
1
Versions
266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recast - npm Package Compare versions

Comparing version 0.4.18 to 0.4.19

11

lib/patcher.js

@@ -179,6 +179,3 @@ var assert = require("assert");

if (!canReprintChildren ||
// Require reprinting if additional parentheses are needed.
(path.needsParens() && !hasParens(oldNode)))
{
if (!canReprintChildren) {
reprints.push({

@@ -222,2 +219,8 @@ newPath: path,

// If this node needs parentheses and will not be wrapped with
// parentheses when reprinted, then return false to skip reprinting
// and let it be printed generically.
if (path.needsParens() && !hasParens(oldNode))
return false;
for (var k in util.getUnionOfKeys(newNode, oldNode)) {

@@ -224,0 +227,0 @@ if (k === "loc")

@@ -15,3 +15,3 @@ {

],
"version": "0.4.18",
"version": "0.4.19",
"homepage": "http://github.com/benjamn/recast",

@@ -18,0 +18,0 @@ "repository": {

@@ -5,2 +5,3 @@ var assert = require("assert");

var Printer = require("../lib/printer").Printer;
var NodePath = require("../lib/path").NodePath;
var util = require("../lib/util");

@@ -169,1 +170,46 @@ var n = require("../lib/types").namedTypes;

};
exports.testNegatedLoopCondition = function(t) {
var ast = parse([
"for (var i = 0; i < 10; ++i) {",
" console.log(i);",
"}"
].join("\n"))
var loop = ast.program.body[0];
var test = loop.test;
var negation = b.unaryExpression("!", test);
assert.strictEqual(
printer.print(negation),
"!(i < 10)"
);
loop.test = negation;
assert.strictEqual(printer.print(ast), [
"for (var i = 0; !(i < 10); ++i) {",
" console.log(i);",
"}"
].join("\n"));
t.finish();
};
exports.testDiscretionaryParens = function(t) {
var code = [
"if (info.line && (i > 0 || !skipFirstLine)) {",
" info = copyLineInfo(info);",
"}"
].join("\n");
var ast = parse(code);
var rightPath = new NodePath(ast).get(
"program", "body", 0, "test", "right");
assert.ok(rightPath.needsParens());
assert.strictEqual(printer.print(ast), code);
t.finish();
};
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