JSPM

  • Created
  • Published
  • Downloads 144036
  • Score
    100M100P100Q156575F

Compose (function(): Promise)es and auto lift non-promise returners to allow queued IO w/o all the boilerplate.

Package Exports

  • compromise

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compromise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Compromise Build Status Browser Support

Allows composition of functions that require a callback. Assumes the callbacks are node style e.g.,:

function (err, data) {
    // Do stuff
}

Usage

Takes a context and series of methods to call on the context. Passes the data portion of the previous callback to the next, thus creating a crude pipeline. For example:

var example = {
    // Notice that get will always receive the signature of the preceding method in the chain
    get: function get(url, methods, callback) {
        callback(null, url, {name: 'foo', age: 42});
    },

    options: function options(url, callback) {
        callback(null, url, {methods: ['get', 'post']});
    },

    post: function post(url, data, callback) {
        callback(null, {success: true});
    }
};

compromise(target, 'options', 'get', 'post')('/foo').then(function (resp) {
    resp.success; // true
});

More to come...