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
604
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.69.1 to 1.70.0

6

lib/tokenize/expressions/object-expression.js

@@ -31,6 +31,8 @@ 'use strict';

if (property.isSpreadElement()) {
maybe.indent(length > 1 || isLogical(property));
const logical = isLogical(property);
maybe.indent(length > 1 || logical || manyLines);
print(property);
if (length > 1) {
if (!logical && (length > 1 || manyLines)) {
print(',');

@@ -37,0 +39,0 @@ print.newline();

@@ -10,5 +10,9 @@ 'use strict';

const {isArrowFunctionExpression} = require('@babel/types');
const {
isArrowFunctionExpression,
isObjectMethod,
} = require('@babel/types');
const isFirstStatement = (path) => path.get('body.0')?.isStatement();
const isMethodOrArrow = (path) => isArrowFunctionExpression(path) || isObjectMethod(path);

@@ -54,3 +58,3 @@ module.exports.BlockStatement = {

if (path.parentPath.isIfStatement() && path.find(isArrowFunctionExpression))
if (path.parentPath.isIfStatement() && path.find(isMethodOrArrow))
return true;

@@ -57,0 +61,0 @@

@@ -20,4 +20,3 @@ 'use strict';

before(path, {print}) {
print.indent();
print.newline();
print.linebreak();
markBefore(path);

@@ -51,6 +50,5 @@ },

after(path, {print}) {
print.indent();
print.newline();
print.linebreak();
markAfter(path);
},
};

@@ -16,4 +16,3 @@ 'use strict';

before(path, {print}) {
print.indent();
print.newline();
print.linebreak();
},

@@ -20,0 +19,0 @@ print(path, {indent, traverse, print}) {

{
"name": "@putout/printer",
"version": "1.69.1",
"version": "1.70.0",
"type": "commonjs",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
"description": "Simplest possible opinionated Babel AST printer fro 🐊Putout",
"homepage": "https://github.com/putoutjs/printer#readme",

@@ -48,2 +48,3 @@ "main": "./lib/printer.js",

"devDependencies": {
"@putout/plugin-printer": "^1.0.0",
"@putout/plugin-react-hooks": "^5.0.0",

@@ -62,4 +63,3 @@ "@putout/test": "^6.0.1",

"nodemon": "^2.0.1",
"putout": "*",
"putout-plugin-printer": "./rules",
"putout": "29",
"supertape": "^8.0.0",

@@ -66,0 +66,0 @@ "try-catch": "^3.0.0"

@@ -8,3 +8,3 @@ # Printer [![NPM version][NPMIMGURL]][NPMURL]

- ☝️ Similar to **Recast**, but simpler and easier in maintenance, since it supports only **Babel**.
- ☝️ Similar to **Recast**, but [twice faster](#speed-comparison), also simpler and easier in maintenance, since it supports only **Babel**.
- ☝️ As opinionated as **Prettier**, but has more user-friendly output and works directly with **AST**.

@@ -26,2 +26,23 @@ - ☝️ Like **ESLint** but works directly with **Babel AST**.

## 🐊 Support of Printer
**Printer** has first class support from 🐊**Putout** with help of [`@putout/plugin-printer`](https://github.com/coderaiser/putout/tree/master/packages/plugin-printer#putoutplugin-printer-). So install:
```sh
npm i @putout/plugin-printer -aD
```
And update `.putout.json`:
```json
{
"printer": "putout",
"plugins": [
"printer"
]
}
```
To benefit from it.
## API

@@ -163,4 +184,39 @@

## Speed Comparison
About speed, for file `speed.js`:
```js
const putout = require('putout');
const {readFileSync} = require('fs');
const parser = require('@babel/parser');
const code = readFileSync('./lib/tokenize/tokenize.js', 'utf8');
const ast = parser.parse(code);
speed('recast');
speed('putout');
function speed(printer) {
console.time(printer);
for (let i = 0; i < 1000; i++) {
putout(code, {
printer,
plugins: [
'remove-unused-variables',
],
});
}
console.timeEnd(printer);
}
```
With contents of [`tokenize.js`](https://github.com/putoutjs/printer/blob/v1.69.1/lib/tokenize/tokenize.js), we have:
![image](https://user-images.githubusercontent.com/1573141/234004942-8f890da3-a145-425f-9040-25924dcfba7b.png)
## License
MIT

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