GithubHelp home page GithubHelp logo

assafdd / pretty-fast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/pretty-fast

0.0 2.0 0.0 40 KB

Pretty Fast is a source-map-generating JavaScript pretty printer, used by the Firefox Developer Tools debugger.

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%

pretty-fast's Introduction

Pretty Fast

Pretty Fast is a source-map-generating JavaScript pretty printer, that is pretty fast.

Build Status

Install

npm install pretty-fast

Usage

var prettyFast = require("pretty-fast");

var uglyJS = "function ugly(){code()}";

var pretty = prettyFast(uglyJS, {
  url: "test.js",
  indent: "  "
});

console.log(pretty.code);
// function ugly() {
//   code()
// }

console.log(pretty.map);
// [object SourceMapGenerator]

(See the mozilla/source-map library for information on SourceMapGenerator instances, and source maps in general.)

Options

  • url - The URL of the JavaScript source being prettified. Used in the generated source map. If you are prettifying JS that isn't from a file or doesn't have a URL, you can use a dummy value, such as "(anonymous)".

  • indent - The string that you want your code indented by. Most people want one of " ", " ", or "\t".

Issues

Please use Bugzilla

Goals

  • To be pretty fast, while still generating source maps.

  • To avoid fully parsing the source text; we should be able to get away with only a tokenizer and some heuristics.

  • Preserve comments.

  • Pretty Fast should be able to run inside Web Workers.

Non-goals

  • Extreme configurability of types of indentation, where curly braces go, etc.

  • To be the very fastest pretty printer in the universe. This goal is unattainable given that generating source maps is a requirement. We just need to be Pretty Fast.

  • To perfectly pretty print exactly as you would have written the code. This falls out from both not wanting to support extreme configurability, and avoiding full on parsing. We just aim to pretty print Pretty Well.

pretty-fast's People

Contributors

fitzgen avatar anaran avatar bgrins avatar bvibber avatar assafdd avatar darkwing avatar jasonlaster avatar tromey avatar zaggy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.