glsl-min-stream

1.0.0 • Public • Published

glsl-min-stream

Transform glsl-parser AST nodes on-the-fly by renaming variables into shorter forms.

var tokenizer = require('glsl-tokenizer')
  , 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()

API

minifier = require('glsl-minifier')([safe_word_list], should_mutate_storages) -> minifier stream

Create a through stream that rewrites incoming declared variables.

  • safe_word_list defaults to ["main"] so that the main function is not overridden.
  • should_mutate_storages, a boolean defaulted to false, determines whether the minifier should attempt to rewrite variables declared as varying, attribute, or uniform (usually you do not want to do this, as the client program is expecting specific variable names).

License

MIT

Package Sidebar

Install

npm i glsl-min-stream

Weekly Downloads

2,023

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mikolalysenko
  • wwwtyro
  • thibauts
  • mikkoh
  • yoshuawuyts
  • mattdesl
  • hughsk
  • chrisdickinson
  • tatumcreative
  • rezaali