1.1.0 • Published 7 years ago

maf-chain v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

maf-chain

data chain object for node.js and browser

stability-unstable

bitHound Overall Score bitHound Dependencies Build Status Coverage Status

NPM

install

npm install --save maf-chain

usage

var Chain = require('maf-chain');

var steps = {
    limit: null,
    skip: null,
    sort: function (data, field, direction) {
        data['sort'] = {
            field: 'direction'
        }
    }
};

var defaults = {
    limit: 10,
    skip: 0
}

var chain = new Chain(steps, defaults);

chain.onExec(function (data) {

    // data =
    {
        limit: 20,
        skip: 0,
        sort: {
            name: 'desc'
        }
    }

    return new Promise((resolve, reject) => {
        // ...
    });

});

chain
    .limit(20)
    .sort('name', 'desc')
    .exec()
    // here return Promise from onExec callback
    .then(() => {

    })

API

see docs/api.md

LICENSE

MIT

1.1.0

7 years ago

1.0.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago