npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

glsl-man

v1.1.14

Published

GLSL parser and code generator based on Google's glsl-unit grammar

Downloads

1,674

Readme

GLSL manipulator

GLSL parser and code generator based on Google's glsl-unit grammar.

NPM

Install

npm install glsl-man

Usage

Parsing

var glsl = require('glsl-man');
var ast = glsl.parse(source);

Deparsing

var glsl = require('glsl-man');
var ast = glsl.parse(source);
var generated = glsl.string(ast);

Querying

var glsl = require('glsl-man');
var ast = glsl.parse(source);
var uniforms = glsl.query.all(
	ast,
	glsl.query.selector('declarator[typeAttribute] > type[qualifier=uniform]'));

API

Parsing

  • glsl.parse(string) - Generates AST from GLSL
    • string - GLSL source code

Deparsing

  • glsl.string(ASTNode, options) - Generates GLSL from AST
    • ASTNode - Any node from the tree returned by parse(string)
    • options - The default options are described below:
	{
		tab: '\t',       // Character used for tab
		space: ' ',      // Character used for space
		newline: '\n',   // Character used for newlines

		// The following should not be altered to produce valid GLSL
		terminator: ';', // Character used to terminate a statement
		comma: ','       // Character used for comma
	}
  • glsl.wrap(ASTNode) - Wraps the given node in a 'root' scope. Useful for generating valid code from arbitrary AST subnodes.
    • ASTNode - Any node from the tree returned by parse(string)

Querying

  • glsl.query.selector(string) - Returns a selector

  • glsl.query.all(node, selector, matches) - Searches the tree depth first and returns all nodes that match the selector

    • node - AST node
    • selector - The selector to test against
    • matches - Array to store matched nodes (optional)
  • glsl.query.first(node, selector) - Searches the tree depth first and returns the first node that matches the selector

    • node - AST node
    • selector - The selector to test against
  • glsl.query.children(node, selector, matches) - Searches only the immediate subnodes of the given node and returns all children that match the selector

    • node - AST node
    • selector - The selector to test against
    • matches - Array to store matched nodes (optional)
  • glsl.query.firstChild(node, selector) - Searches only the immediate subnodes of the given node and returns the first node that matches the selector

    • node - AST node
    • selector - The selector to test against
  • glsl.query.subnodes(node) - Returns a list of all subnodes of the given node that can be further traversed

    • node - AST node

Modifying

  • glsl.mod.find(node) - Returns an object with index and statements keys.

    • node - AST node
  • glsl.mod.remove(node) - Removes the given node from it's AST.

    • node - AST node
  • glsl.mod.replace(node, newNode) - Replaces the given node with newNode.

    • node - AST node
    • newNode - AST node or Array of AST nodes
  • glsl.mod.add(node, newNode, after) - Inserts newNode before or after node.

    • node - AST node
    • newNode - AST node or Array of AST nodes
    • after - (optional) Boolean
  • glsl.mod.addBefore(node, newNode) - Shortcut to glsl.mod.add.

  • glsl.mod.addAfter(node, newNode) - Shortcut to glsl.mod.add.