Transform glsl-parser AST nodes on-the-fly by renaming variables into shorter forms.
var tokenizer = require('glsl-tokenizer/stream')
, parser = require('glsl-parser')
, deparser = require('glsl-deparser')
, minify = require('./index')
process.stdin
.pipe(tokenizer())
.pipe(parser())
.pipe(minify()) // <-- the minifier
.pipe(deparser(false)) // <-- "false" == no unnecessary whitespace, please.
.pipe(process.stdout)
process.stdin.resume()Create a through stream that rewrites incoming declared variables.
safe_word_listdefaults to["main"]so that the main function is not overridden.should_mutate_storages, a boolean defaulted tofalse, determines whether the minifier should attempt to rewrite variables declared asvarying,attribute, oruniform(usually you do not want to do this, as the client program is expecting specific variable names).
Run npm test to run tests
When adding a code change that differs the output, make sure to run tap with snapshots by running npm run test -- --snapshot. This will regenerate the tap-snapshot files. Make sure to commit those along with other code and test changes.
MIT