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

@andrewray/glsl-preprocessor

v1.0.1

Published

Preprocess GLSL source code

Downloads

4

Readme

A GLSL preprocessor based on the C-Preprocessor library.

Usage

import Preprocessor from '@andrewray/glsl-preprocessor';

const result = new Preprocessor(options).preprocess(src);

Options

This are the defaults options. You can modify them by passing an option object.

var options = {
  // Predefined constants (ex: { "MY_CONST": "42" })
  constants: {},

  // Predefined macros (ex: { "MACRO": "(a,b) a+b" })
  macros: {},

  // End of line character
  newLine: '\n',

  // Escape '//#' & '/*#' comments (see extra/comments)
  commentEscape: true,

  // Empty lines to add between code and included files
  includeSpaces: 0,

  // Limit of empty following lines (0 = no limit)
  emptyLinesLimit: 0,

  // Base path for including files
  basePath: './'
};

Features

Define
// Define a constant
#define MY_CONST 42

// Define a macro
#define SUM(a,b) a + b

Create a constant or a macro.

Undefine
#undef MY_CONST

Delete a constant or a macro.

Condition
#if A + B == 5 && defined(MY_CONST)
  // Do stuff
#elif "MY_CONST2" == "House"
  // Do other stuff
#else
  // Do other stuff
#endif

#ifndef MY_CONST3
  // Do stuff
#endif

C like conditions.
#if condition is evaluated in JS so you must add " between string constants.
Note: #ifdef C and #ifndef C are faster than #if defined(C) and #if !defined(C).

Error
#error This is an error

Stop the compiler and raise the error.

Extra

Compiler constants
__LINE__ // Current line (where this constant is used).
__FILE__ // Current file (where this constant is used).

This constants are predefined by the compiler.

Comments
//# One line comment

/*#

Multi-lines comment

#*/

This comments will be deleted in the compiled file.
Note: options.commentEscape must be true.