JavaScript.beautify()

Beautify a JavaScript code string.

Usage

Hover over inputs/exits for more info.

var JavaScript = require('machinepack-javascript');


// Beautify a JavaScript code string.

JavaScript.beautify({

code: 'alert(\n"hi it\'s me" + \n\' and i sure am messy")\nvar x =1+1;\n',

useTabs: false,

numSpaces: 2,

}).execSync();

Inputs

code required

The JavaScript code to beautify.

'alert(\n"hi it\'s me" + \n\' and i sure am messy")\nvar x   =1+1;\n'
useTabs

Whether to use tabs instead of spaces (defaults to 2 spaces)

false
numSpaces

The number of spaces that should represent an indentation.

2

Exits

error

An unexpected error occurred.

success

OK.

'alert("hi it\'s me" + \n" and i sure am messy");\nvar x = 1+1;\n'