Utility methods (pretty printer, summarizer) for printing Shift ASTs
npm install shift-printershift-printer is a module that exposes common ways you would probably want to print out JavaScript ASTs. It's a lightweight wrapper around shift-codegen that reduces the boilerplate around printing and logging.
``sh`
$ npm install shift-printer
`js
const codegen = require('shift-printer');
const { parseScript } = require('shift-parser');
const ast = parseScript(function test(a,b,c) { return a+b+c; } test(1,2,3));
const src = codegen.prettyPrint(ast);
console.log(src);
// the above two lines can be written as:
codegen.log(ast);
`
Prints with linebreaks, indentation, and spaces.
alias of .prettyPrint()
Prints minimal source representation.
Prints truncated source e.g. function test(a,b,c) { ...
Node-specific print rules e.g. function test(a, b, c) { ... }`
console.log(print(ast))
console.log(printTruncated(ast, length, overflow))
console.log(printTerse(ast));