Trim the whitespace within an array of GLSL tokens
Last updated 5 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-token-whitespace-trim 
SYNC missed versions from official npm registry.



Trim the whitespace within an array of GLSL tokens provided by glsl-tokenizer. Useful for minimising shader source size, especially after heavy processing steps such as seen in glslify or as part of a GLSL minifier.



trim(tokens, [all])

Trims the whitespace in an array of GLSL tokens. By default, this will trim repeated to newlines such that no more than two newlines will appear in a row.

If you're more concerned about size than aesthetics, you can pass true as the second argument to remove all extraneous whitespace (more or less).

const tokenize = require('glsl-tokenizer')
const string = require('glsl-token-string')
const trim = require('glsl-token-whitespace-trim')
const fs = require('fs')

const src = fs.readFileSync('shader.glsl', 'utf8')
const tokens = tokenize(src)

trim(tokens, true)

const trimmed = string(tokens)


MIT, see for details.

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

1 Versions

  • 1.0.0                                ...           5 years ago
Today 0
This Week 333
This Month 837
Last Day 34
Last Week 445
Last Month 1,985
Dependencies (0)
Dev Dependencies (7)

Copyright 2014 - 2016 © |