prepr
Version:
Preprocess string in C/GLSL-preprocessor fashion
47 lines (33 loc) • 874 B
Markdown
> Preprocess any string in C/GLSL-preprocessor fashion.
[](https://npmjs.org/package/prepr/)
```js
import prepr from 'prepr';
prepr(`
var a = A;
//too far
//too close
//about right
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](https://github.com/stackgl/glsl-transpiler), so some [C-preprocessor](https://gcc.gnu.org/onlinedocs/cpp/index.html#Top) functionality is absent, but the project is welcome to forks and PRs.
* [compile-js-like-c](https://github.com/ParksProjets/compile-js-like-c) — another C preprocessor for js.