https://github.com/json2d/glsl-detokenizer
a through stream that reads from a GLSL token object stream and writes back a stream of GLSL token strings
https://github.com/json2d/glsl-detokenizer
Last synced: 3 months ago
JSON representation
a through stream that reads from a GLSL token object stream and writes back a stream of GLSL token strings
- Host: GitHub
- URL: https://github.com/json2d/glsl-detokenizer
- Owner: json2d
- License: mit
- Created: 2017-07-12T18:47:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-14T20:08:25.000Z (almost 8 years ago)
- Last Synced: 2025-03-16T09:42:13.587Z (4 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# glsl-detokenizer
A through stream that reads from a GLSL token object stream and writes back a stream of GLSL token strings
Works with token object stream created by [stackgl/glsl-tokenizer](https://github.com/stackgl/glsl-tokenizer)
``` javascript
// Streaming API:
var tokenizer = require('glsl-tokenizer/stream')
var detokenizer = require('glsl-detokenizer/stream')
var fs = require('fs')const glslIn = fs.createReadStream('some.glsl')
const glslOut = fs.createReadStream('some-modded.glsl')glslIn
.pipe(tokenizer())
.on('data', function(token) {
if(token.type == 'float') {
token.data = '1.0'; // change all float literals to 1.0
}
})
.pipe(detokenizer())
.pipe(glslOut)// Synchronously:
var tokenizer = require('glsl-tokenizer/string')
var detokenizer = require('glsl-detokenizer/string')
var fs = require('fs')const tokens = tokenizerString(fs.readFileSync('some.glsl'))
tokens.forEach( token => {
if(token.type == 'float') {
token.data = '1.0'; // change all float literals to 1.0
}
})
fs.writeFileSync('some-modded.glsl',detokenizerString(tokens))```
# License
MIT, see [LICENSE.md](LICENSE.md) for further information.