# glsl-token-whitespace-trim

> Trim the whitespace within an array of GLSL tokens

Latest version **1.0.0** (published 2015-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install glsl-token-whitespace-trim
pnpm add glsl-token-whitespace-trim
yarn add glsl-token-whitespace-trim
bun add glsl-token-whitespace-trim
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-11-24 |
| First published | 2015-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | glsl, token, tokenizer, glslify, ecosystem:stackgl, whitespace, trim |

## Links

- npm: https://www.npmjs.com/package/glsl-token-whitespace-trim
- Repository: https://github.com/hughsk/glsl-token-whitespace-trim
- Issues: https://github.com/hughsk/glsl-token-whitespace-trim/issues
- npm.io page: https://npm.io/package/glsl-token-whitespace-trim

## Recent versions

- 1.0.0 (latest) — 2015-11-24

## README

# glsl-token-whitespace-trim

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Trim the whitespace within an array of GLSL tokens provided by [glsl-tokenizer](https://github.com/stackgl/glsl-tokenizer). Useful for minimising shader source size, especially after heavy processing steps such as seen in [glslify](http://github.com/stackgl/glslify) or as part of a GLSL minifier.

## Usage

[![NPM](https://nodei.co/npm/glsl-token-whitespace-trim.png)](https://www.npmjs.com/package/glsl-token-whitespace-trim)

### `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).

``` javascript
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](http://github.com/hughsk/glsl-token-whitespace-trim/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/glsl-token-whitespace-trim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
