node package manager


Stak Build Status

Create re-usable stacks of code to run.

Status: beta


var stack = Stak.make(
    function readSelf() {
    function capitalize(err, text) {, text.toUpperCase());
    uri: __filename,
    floor: function showIt(err, newText) {
        if (err) throw err;


Similar to Step except you create a stack that can be re-used. This means you create the functions once and pass data in through the this context.


Stak.make(...) link

Shortcut for Object.create(Stak).constructor(...)

Stak.make(function () {
}, function (value) {
    assert(value === true);

Stak.use(...) link

Add extra functions to the stack

var s = Stak.make();
s.use(function () {
    console.log("it works");
s.handle(); // it works 

Stak.handle(context) link

This starts a stack. The first function in the stack will be called and the next function will be called once the first function calls The context object is passed in as this.

var context = {};
var s = Stak.make(function () { assert(this === context); });

The context also has two special properties floor and ceil which form the floor and the ceiling of the stack of functions. This allows you to add a function before and after all the other functions

var stack = Stak.make(function (data) { * this.multiplier);
    multiplier: 3,
    ceil: function () {;
    floor: function (data) {
        assert(data === 42 * 3);

Stak.floor link

A default floor for this instance of the stack. If no floor is passed through handle then this floor will be used

Stak.ceil link

A default ceiling for this instance of the stack. If no ceil is passed through handle then this ceil will be used


npm install stak


make test


  • Raynos

MIT Licenced