-
-
Save chrisdickinson/75def135193cfebbde94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parsing `x ? y : z`: got `x ? y : z;` | |
parsing `"anything" + (x ? y : z) + "anything"`: got `"anything" + (x ? y : z) + "anything";` | |
burrito `x ? y : z`: got `x ? y : z;` | |
burrito `"anything" + (x ? y : z) + "anything"`: got `"anything" + x ? y : z + "anything";` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uglify = require('uglify-js'); | |
var parser = uglify.parser; | |
var burrito = require('burrito'); | |
var parse = function (expr) { | |
var ast = parser.parse.apply(null, arguments); | |
return ast; | |
}; | |
var deparse = function (ast) { | |
return uglify.uglify.gen_code(ast, { beautify : true }); | |
}; | |
console.log('parsing `x ? y : z`: got `%s`', deparse(parse('x ? y : z'))); | |
console.log('parsing `"anything" + (x ? y : z) + "anything"`: got `%s`', deparse(parse('"anything" + (x ? y : z) + "anything"'))); | |
console.log('burrito `x ? y : z`: got `%s`', burrito('x ? y : z')); | |
console.log('burrito `"anything" + (x ? y : z) + "anything"`: got `%s`', burrito('"anything" + (x ? y : z) + "anything"')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment