You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
572 B
24 lines
572 B
const maxstache = require('maxstache') |
|
const through = require('through2') |
|
const assert = require('assert') |
|
const split = require('split2') |
|
const pump = require('pump') |
|
|
|
module.exports = maxstacheStream |
|
|
|
// split by newline and parse |
|
// obj? -> stream |
|
function maxstacheStream (args) { |
|
args = args || {} |
|
assert.equal(typeof args, 'object') |
|
return pump(split(), parse(args)) |
|
} |
|
|
|
// Maxstache transform stream |
|
// obj? -> stream |
|
function parse (args) { |
|
return through(function (chunk, enc, cb) { |
|
const str = String(chunk) |
|
cb(null, maxstache(str, args)) |
|
}) |
|
}
|
|
|