[go: up one dir, main page]

Skip to content

dy/prepr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Preprocess any string in C/GLSL-preprocessor fashion.

npm install prepr

import prepr from 'prepr';

prepr(`
	#define A 2;

	#ifdef A
	var a = A;
	#endif

	#if A > 40
	//too far
	#elif A < 1
	//too close
	#else
	//about right
	#endif

	var b = myVar;
	var c = myMacro('xyz');
`, {
	myVar: 1,
	myMacro: function (arg) { return arg; }
});

// ↓

`
var a = 2;

//about right

var b = 1;
var c = 'xyz';
`

The primary purpose is to preprocess code for glsl-transpiler, so some C-preprocessor functionality is absent, but the project is welcome to forks and PRs.

Related