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
602
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.20.0 to 1.21.0

6

lib/tokenize/debug.js

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

return (chunk) => {
if (chunk) {
return (...args) => {
const [chunk] = args;
if (args.length) {
chunks.push(chunk);

@@ -59,0 +61,0 @@ return;

'use strict';
const {
isMarkedParentBefore,
hasPrevNewline,
} = require('../mark');
const CallExpression = {
beforeIf(path) {
return isNewLineBefore(path) && !isMarkedParentBefore(path) && !hasPrevNewline(path.parentPath);
},
before(path, {print}) {
print.breakline();
},
print(path, {indent, print, maybe}) {

@@ -60,23 +49,2 @@ const isParentCall = toLong(path) && path.parentPath.isCallExpression();

function isNewLineBefore({parentPath}) {
if (!parentPath.isExpressionStatement())
return false;
const prevPath = parentPath.getPrevSibling();
const prevPrevPath = prevPath.getPrevSibling();
if (prevPath.isStatement() && !prevPath.isExpressionStatement() && !prevPath.isVariableDeclaration())
return true;
const twoPrev = prevPath.node && prevPrevPath.node;
if (!twoPrev)
return false;
if (prevPath.isExpressionStatement() && prevPath.get('expression').isCallExpression())
return false;
return true;
}
function toLong(path) {

@@ -83,0 +51,0 @@ const args = path.get('arguments');

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

print('}');
maybe.print.newline(path.parentPath.isLogicalExpression());
maybe.print.newline(shouldAddNewline(path));
maybe.print(parens, ')');
};
function shouldAddNewline(path) {
if (!path.parentPath.isLogicalExpression())
return false;
return path.parentPath.parentPath.isSpreadElement();
}
module.exports.ObjectProperty = (path, {print, maybe}) => {

@@ -61,0 +68,0 @@ const {

'use strict';
const {isMarkedAfter} = require('./mark');
const isParentProgram = (path) => path.parentPath?.isProgram();

@@ -12,2 +13,5 @@ const isParentBlock = (path) => path.parentPath.isBlockStatement();

if (isMarkedAfter(path.get('body')))
return false;
return !next.isEmptyStatement();

@@ -14,0 +18,0 @@ };

@@ -17,9 +17,4 @@ 'use strict';

}
module.exports.isMarkedBefore = isMarkedBefore;
module.exports.isMarkedAfter = isMarkedAfter;
function isMarkedBefore(path) {
return path[WATER_MARK_BEFORE];
}
function isMarkedAfter(path) {

@@ -31,5 +26,1 @@ return path[WATER_MARK_AFTER];

};
module.exports.isMarkedParentBefore = (path) => {
return isMarkedBefore(path.parentPath);
};
'use strict';
const {
isNext,
isParentBlock,

@@ -18,7 +17,10 @@ isNextParent,

afterIf(path) {
if (!isNext(path) && !isParentBlock(path) && !isNextParent(path))
return false;
if (isParentBlock(path))
return true;
return true;
if (isNextParent(path))
return true;
return false;
},
};

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

return false;
return path.findParent(isNext);
}

@@ -89,1 +89,2 @@

}

@@ -14,38 +14,43 @@ 'use strict';

module.exports.ForOfStatement = (path, {indent, print, maybe}) => {
if (!isFirst(path) && !hasPrevNewline(path)) {
module.exports.ForOfStatement = {
beforeIf(path) {
return !isFirst(path) && !hasPrevNewline(path);
},
before(path, {print}) {
print.indent();
print.newline();
markBefore(path);
}
indent();
print('for (');
print('__left');
print(' of ');
print('__right');
print(')');
const bodyPath = path.get('body');
if (bodyPath.isExpressionStatement()) {
indent.inc();
print.newline();
print('__body');
indent.dec();
maybe.print.newline(isNext(path));
},
print(path, {indent, print, maybe}) {
indent();
print('for (');
print('__left');
print(' of ');
print('__right');
print(')');
return;
}
if (bodyPath.isBlockStatement()) {
print(' ');
print('__body');
}
if (isNext(path)) {
const bodyPath = path.get('body');
if (bodyPath.isExpressionStatement()) {
indent.inc();
print.newline();
print('__body');
indent.dec();
maybe.print.newline(isNext(path));
return;
}
if (bodyPath.isBlockStatement()) {
print(' ');
print('__body');
}
},
afterIf: isNext,
after(path, {print}) {
print.indent();
print.newline();
markAfter(path);
}
},
};

@@ -40,8 +40,7 @@ 'use strict';

} else if (alternate.isIfStatement()) {
print.space();
write.space();
write('else');
print.space();
write.space();
traverse(alternate);
} else if (alternate.node) {
print.breakline();
write('else');

@@ -54,6 +53,4 @@ print.newline();

const next = path.getNextSibling();
if (next.isExpressionStatement() && !next.get('expression').isCallExpression())
print.newline();
//if (shouldAddNewline(path))
//print.newline();
},

@@ -60,0 +57,0 @@ afterIf: (path) => {

@@ -17,5 +17,6 @@ 'use strict';

print(finalizer);
print.newline();
}
print.newline();
maybe.print.breakline(isNext(path));

@@ -22,0 +23,0 @@ };

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

maybe.print(initPath.node, ' = ');
print(initPath);
print('__declarations.0.init');
maybe.print(isParentBlock(path), ';');

@@ -64,2 +64,3 @@

const next = path.getNextSibling();
const prev = path.getPrevSibling();

@@ -69,2 +70,5 @@ if (isCoupleLines(next))

if (prev.isVariableDeclaration() && !next.isVariableDeclaration())
return true;
return false;

@@ -71,0 +75,0 @@ }

{
"name": "@putout/printer",
"version": "1.20.0",
"version": "1.21.0",
"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