prepr
Preprocess string in C/GLSL-preprocessor fashion
Last updated a year ago by dy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install prepr 
SYNC missed versions from official npm registry.

Preprocess any string in C/GLSL-preprocessor fashion.

npm install prepr

var prepr = require('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

Current Tags

  • 1.2.4                                ...           latest (a year ago)

9 Versions

  • 1.2.4                                ...           a year ago
  • 1.2.3                                ...           2 years ago
  • 1.2.2                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 5
Last Day 0
Last Week 1
Last Month 28
Dependencies (6)
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |