Socket
Socket
Sign inDemoInstall

glsl-token-whitespace-trim

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    glsl-token-whitespace-trim

Trim the whitespace within an array of GLSL tokens


Version published
Weekly downloads
234K
increased by0.39%
Maintainers
1
Install size
7.32 kB
Created
Weekly downloads
 

Readme

Source

glsl-token-whitespace-trim

stable

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.

Usage

NPM

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)

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Last updated on 24 Nov 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc