Command line interface to http://jsnice.org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

35 lines
697 B

var http = require('http');
module.exports.nicify = function(js, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
var reqOptions = {
hostname: 'www.jsnice.org',
path: '/beautify?pretty=1&rename=1&types=1&suggest=0',
port: 80,
method: 'POST',
};
var req = http.request(reqOptions, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk.toString();
});
res.on('end', function() {
data = JSON.parse(data);
callback(data);
});
});
req.on('error', function(err) {
console.dir(err);
});
req.write(js);
req.end();
};