diff --git a/lib/index.js b/lib/index.js index 3fdd263..b66fad2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,7 @@ -module.exports = deparse_stream +module.exports = { + deparse: deparse, + deparseString: deparseString +}; var through = require('through') , language = require('cssauron-glsl') @@ -82,6 +85,14 @@ function deparse_stream(with_whitespace, indent) { } } +function deparseString(n, with_whitespace, indent) { + output.length = 0; + with_whitespace = with_whitespace === undefined ? true : with_whitespace; + ws = new WSManager(with_whitespace, indent || ' '); + deparse(n); + return output.join(''); +} + function deparse(n) { return types[n.type](n) } @@ -376,7 +387,7 @@ function deparse_stmt(node) { } function deparse_stmtlist(node) { - var has_parent = node.parent !== null + var has_parent = node.parent !== null && node.parent !== undefined; if(has_parent) { output.push('{')