Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@putout/printer
Advanced tools
Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout
Prints Babel AST to readable JavaScript.
npm i @putout/printer
const {print} = require('@putout/printer');
const {parse} = require('@babel/parser');
const ast = parse('const a = (b, c) => {const d = 5; return a;}');
print(ast);
// returns
// returns
`
const a = (b, c) => {
const d = 5;
return a;
};
`;
When you need to extend syntax of @putout/printer
just pass a function which receives:
path
, Babel Pathprint
, a function to output result of printing into token array;When path
contains to dashes __
and name, it is the same as: print(path.get('right'))
, and this is
actually traverse(path.get('right'))
shortened to simplify read and process.
Here is how you can override AssignmentPattern
:
const ast = parse('const {a = 5} = b');
print(ast, {
format: {
indent: ' ',
},
visitors: {
AssignmentPattern(path, {print}) {
print(' /* [hello world] */= ');
print('__right');
},
},
});
// returns
// returns
'const {a /* [hello world] */= 5} = b;\n';
MIT
FAQs
Simplest possible opinionated Babel AST printer for 🐊Putout
The npm package @putout/printer receives a total of 7,369 weekly downloads. As such, @putout/printer popularity was classified as popular.
We found that @putout/printer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.