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

@putout/printer

Package Overview
Dependencies
Maintainers
1
Versions
599
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/printer - npm Package Compare versions

Comparing version 1.14.2 to 1.14.3

10

lib/tokenize/statements/for-statement.js

@@ -6,3 +6,3 @@ 'use strict';

module.exports.ForStatement = {
print(path, {print, maybe, indent}) {
print(path, {print, maybe}) {
const {

@@ -28,6 +28,8 @@ test,

} else {
print.newline();
indent.inc();
const is = !path.get('body').isEmptyStatement();
maybe.print.newline(is);
maybe.indent.inc(is);
print('__body');
indent.dec();
maybe.indent.dec(is);
}

@@ -34,0 +36,0 @@ },

92

lib/tokenize/statements/if-statement.js

@@ -6,45 +6,55 @@ 'use strict';

module.exports.IfStatement = (path, {indent, print}) => {
if (shouldAddNewlineBefore(path)) {
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
module.exports.IfStatement = {
before: (path, {print}) => {
print.linebreak();
}
indent();
print('if (');
print('__test');
print(')');
const consequent = path.get('consequent');
const alternate = path.get('alternate');
if (consequent.isBlockStatement()) {
print(' ');
print(consequent);
} else {
},
beforeIf: shouldAddNewlineBefore,
print: (path, {indent, print, maybe}) => {
indent();
print('if (');
print('__test');
print(')');
const consequent = path.get('consequent');
const alternate = path.get('alternate');
if (consequent.isBlockStatement()) {
print(' ');
print(consequent);
} else {
const is = !isEmptyConsequent(path);
maybe.print.newline(is);
maybe.indent.inc(is);
print(consequent);
maybe.indent.dec(is);
}
if (alternate.isBlockStatement()) {
print(' else ');
print(alternate);
} else if (alternate.node) {
print.breakline();
print('else');
print.newline();
indent.inc();
print(alternate);
indent.dec();
}
},
afterIf: (path) => {
const next = path.getNextSibling();
if (!next.node || next.isExpressionStatement() || next.isReturnStatement())
return false;
return true;
},
after: (path, {print}) => {
print.indent();
print.newline();
indent.inc();
print(consequent);
indent.dec();
}
if (alternate.isBlockStatement()) {
print(' else ');
print(alternate);
} else if (alternate.node) {
print.breakline();
print('else');
print.newline();
indent.inc();
print(alternate);
indent.dec();
}
const next = path.getNextSibling();
if (!next.node || next.isExpressionStatement() || next.isReturnStatement())
return;
print.indent();
print.newline();
markAfter(path);
markAfter(path);
},
};

@@ -51,0 +61,0 @@

@@ -38,3 +38,5 @@ 'use strict';

},
EmptyStatement({}) {},
EmptyStatement(path, {write}) {
write(';');
},
InterpreterDirective(path, {print}) {

@@ -41,0 +43,0 @@ print(`#!${path.node.value}`);

{
"name": "@putout/printer",
"version": "1.14.2",
"version": "1.14.3",
"type": "commonjs",

@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

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