rdio/jsfmt — pull request #39 by brettlangdon (2014-05-21 16:27:24+00:00)
Title: prototype format diffs from api

this is just a crazy prototype/idea I had when pondering #8

basically trying to expose the ability to run a diff from the api. currently the way the code is we would have to change the api to accept callbacks, so I decided to give it a shot without really changing the public facing api very much.

it can be used like:

```javascript
var jsfmt = require('jsfmt');

var code = 'var test=require("test");if(1){test.test();}';

var config = jsfmt.getConfig();
config.diff = true;
var diff = jsfmt.format(code, config);
console.log(diff);
```
will output

```diff
+ var test = require("test");
+ if (1) {
+ test.test();
+ }
- var test = require("test");if(1){test.test();}
```

`config.diff` can accept, `raw` (this is the raw response from the [diff](https://www.npmjs.org/package/diff) module), `formatted` (thinking maybe I should rename to 'pretty' or something better) or `true` which gives the above result (with '+', '-', etc and colors) or anything else will result in returning the normal just formatted output.

The main thing that we lose are that it isn't a true "diff" so you cannot create a patch from it. Also right now if the file has changed at all then it shows the changes for the whole file not just the changed plus some context.

so that all said, I think I am meh about this change, dont mind if it gets a :thumbsdown: and scrapped.