Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

glsl-token-extract-version

Jam317MIT1.0.1

finds a #version field in a set of GLSL tokens

glsl, get, version, find, 300, 100, es, stackgl, glslify, token, tokenizer

readme

glsl-token-extract-version

stable

Gets the value of a #version statement from a set of GLSL tokens, or returns null if no version is defined.

var tokenize = require('glsl-tokenizer')
var getVersion = require('glsl-token-extract-version')

var source = `
  #version 300 es // WebGL 2
  out vec4 fragColor;

  void main() {
    fragColor = vec4(1.0);
  }
`

var version = getVersion(tokenize(source))
//=> "300 es"

Usage

NPM

version = getVersion(tokens)

For the given list of GLSL tokens, finds a preprocessor statement that matches a #version regex. Normalizes multiple whitespace into a single space, and returns the string value, such as "300 es" or "100".

If no #version statement exists, returns null.

License

MIT, see LICENSE.md for details.