Expand description
prettify-js is a tokenizer-based JS prettyprinter that generates source maps.
Example:
let (pretty, _) = prettify_js::prettyprint("function x(a){return a;}");
assert_eq!(pretty, "function x(a) {\n return a;\n}\n");
Structs§
- Source
Coord - Source coordinate, line+column
- Source
MapColumn - Zero-based column number, in UTF16 code units
- Source
MapLine - Zero-based line number
- Source
Mapping - Points that correspond in the original/generated source code.
Functions§
- generate_
source_ map - Generate a source-map as a string, given the original source file name, file data, and a list of mappings from the original source to the generated source.
- maybe_
prettyprint - Convenience function to create a sourcemap for the prettyprinted version of the file (if it needs prettyprinting), generate a URL for it and append that URL to the file text so it gets used.
- prettyprint
- Prettyprint JS source code. Returns the prettyprinted code, plus a list of SourceMappings in source order (both in original and prettyprinted code … we don’t reorder code).
- should_
prettyprint - Uses a heuristic to decide if the source file needs prettyprinting: whether its average line length is > 100.