Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
/ compromise Public archive

Compose (function(): Promise)es and convert callback takers to promise givers w/o all the boilerplate.

License

Notifications You must be signed in to change notification settings

jnewman/compromise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compromise Build Status Browser Support

I've given up my slot on npm to the more popular nlp_compromise. If you need this for your project the old versions will remain at <=0.1.1.

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...

About

Compose (function(): Promise)es and convert callback takers to promise givers w/o all the boilerplate.

Resources

License

Stars

Watchers

Forks

Packages

No packages published