Work in progress!
npm install m4
$ node example.jsboop
// example.js'use strict';var M4 = require'm4';var input = ;inputpipeM4pipeprocessstdout;inputwrite"define(`beep', `boop')dnl\nbeep\n";inputend;
Inherit stream.Transform. As such this is a duplex stream you can pipe, write and read.
nestingLimitNumber Maximum nested macro calls. Beware, this does not prevent endless rescanning loops.
Signal a non-recuperable error. The stream will not produce further output in the case of an error.
Signal a warning. The steam continues to produce output normally, but there may be some unwanted behavior.
fnFonction Called with
(name, [arg1, arg2 ... ]), must return the macro expansion result as a string.
nameis the macro defined name itself.
strString Macro content, just like you were defining the macro in M4.
indexNumber Diversion index.
Change how the output is processed. If the index is zero, output is directly emitted by the stream. If the index is a positive integer, the output is stored in an internal buffer — a "diversion" — instead.
diversionsNumber Diversion indices.
Output the content of the specified diversions. They are emptied. If no diversion is specified, all of them are undiverted, in numerical order.
Put the stream into a special mode where all the tokens are ignored until the next newline.