Tamarack(.js)
This is a NodeJS port of the similarly named framework for .NET, written by Mike Valenty. The documentation on that page is more verbose than the stuff on this page. That's because the APIs are pretty much identical except for the case of the first letter in the functions. And there's less angle brackets in the JavaScript version.
Installation
Node
npm install tamarack
Browser
Reference tamarack.min.js somewhere, and use window.tamarack
.
Usage
You start with a Pipeline
. Pipeline
s contain filters. In the dynamic, non-type-safe
JavaScript world, a filter is just an object that has an executeSync
function on it.
Here is the simplest filter of them all:
var simpleFilter = { return ; };
var Pipeline = Pipeline; { var pipeline = ; return pipeline;}
Here's what one of these filters might look like:
{} RewriteProfanityprototype = { input = input; return ; };
Asynchronous Pipelines
Two things to do when handling asynchronous filters and pipelines:
- Add an
execute(input, next, callback)
function to your filter - Call
execute(input, null, callback)
on the pipeline
For example, here's an asynchronous filter:
{ thisword = word;}AppendWordprototype = { input += thisword; ; };
And then how you use it in a pipeline:
;
If you want to modify the output using an asynchronous filter,
AppendWord.prototype.execute
would become:
{ var self = this; ;}
The result after executing the pipeline as above would be Hello !world
.
Development
git clone git@github.com:tmont/tamarackjs.gitcd tamarackjsnpm installnode_modules/.bin/grunt test
- Run
node_modules/.bin/grunt build
to create the minified browser version of tamarack. - Run
node_modules/.bin/grunt coverage
for code coverage. - Run
node_modules/.bin/grunt release
to prepare a release build.