🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

glsl-tokenizer

Package Overview
Dependencies
Maintainers
17
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-tokenizer

r/w stream of glsl tokens

2.1.5
latest
Source
npm
Version published
Weekly downloads
328K
-11.85%
Maintainers
17
Weekly downloads
 
Created

What is glsl-tokenizer?

The glsl-tokenizer npm package is a tool for tokenizing GLSL (OpenGL Shading Language) code. It breaks down GLSL code into a stream of tokens, which can then be used for further processing, such as parsing, analysis, or transformation.

What are glsl-tokenizer's main functionalities?

Tokenizing GLSL code

This feature allows you to tokenize a GLSL shader code. The code sample reads a GLSL file, tokenizes its content, and prints the tokens to the console.

const tokenize = require('glsl-tokenizer');
const fs = require('fs');

const glslCode = fs.readFileSync('shader.glsl', 'utf8');
const tokens = tokenize(glslCode);
console.log(tokens);

Handling different types of tokens

This feature demonstrates how to handle different types of tokens produced by the tokenizer. The code sample tokenizes a simple GLSL code snippet and prints the type and data of each token.

const tokenize = require('glsl-tokenizer');

const glslCode = 'void main() { gl_FragColor = vec4(1.0); }';
const tokens = tokenize(glslCode);

for (const token of tokens) {
  console.log(`Type: ${token.type}, Data: ${token.data}`);
}

Customizing tokenization

This feature shows how to customize the tokenization process by specifying options. The code sample tokenizes GLSL code with a specified GLSL version.

const tokenize = require('glsl-tokenizer');

const glslCode = 'void main() { gl_FragColor = vec4(1.0); }';
const tokens = tokenize(glslCode, { version: '300 es' });

console.log(tokens);

Other packages similar to glsl-tokenizer

Keywords

glsl

FAQs

Package last updated on 06 Oct 2018

Did you know?

Socket

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