New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shift-printer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shift-printer

Utility methods (pretty printer, summarizer) for printing Shift ASTs

latest
npmnpm
Version
1.0.1
Version published
Weekly downloads
302
46.6%
Maintainers
1
Weekly downloads
 
Created
Source

Shift Printer

shift-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.

Status

Stable.

Installation

$ npm install shift-printer

Usage

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);

API

.prettyPrint(ast)

Prints with linebreaks, indentation, and spaces.

.print(ast)

alias of .prettyPrint()

.printTerse(ast)

Prints minimal source representation.

.prettyTruncated(ast, length = 50, overflow = '...')

Prints truncated source e.g. function test(a,b,c) { ...

.printSummary(ast)

Node-specific print rules e.g. function test(a, b, c) { ... }

log(ast)

console.log(print(ast))

logTruncated(ast, length = 50, overflow = '...')

console.log(printTruncated(ast, length, overflow))

logTerse(ast)

console.log(printTerse(ast));

FAQs

Package last updated on 21 May 2020

Did you know?

Socket

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.

Install

Related posts