npm.io
0.2.3 • Published 12 years ago

token-filter

Licence
MIT
Version
0.2.3
Deps
0
Vulns
0
Weekly
0

token-filter

A Transform stream that replaces delimited keys (tokens) with matching values, like the Ant Filter task.

Build Status

Usage

var fs = require('fs');
var tokenFilter = require('token-filter');

// input.txt => "Hello, @name@!"
fs.createReadStream('input.txt')
    .pipe(tokenFilter({ name: "World" }))
    .pipe(fs.createWriteStream('output.txt'));
// output.txt => "Hello, World!"

API

tokenFilter(context, [options])
  • context {Object} Values to interpolate into matched keys.
  • options {Object} (optional)
    • tokenDelimiter {String} The string that begins and ends a token (default "@").
    • highWaterMark {Number} The stream's highWaterMark, defaulting to fs.ReadStream's default (64KB).

Additional stream options are detailed in the core manual.

Keywords