Monocart Formatter
JS/CSS/HTML/JSON formatter
Features
- Base on js-beautify
- Generating mapping after formatted
- Working with web worker in browser
- Working with worker threads in Node.js
- Minifying worker code with gzip
Install
npm i monocart-formatter
Usage
import { format, MappingParser } from 'monocart-formatter';
const text = "var a = 1;";
const type = "js";
const options = {};
const { content, mapping } = await format(text, type, options);
console.log("formatted content", content);
const mappingParser = new MappingParser(mapping);
const formattedPosition = mappingParser.originalToFormatted(10);
const originalPosition = mappingParser.formattedToOriginal(formattedPosition);