zames
converts callback-based functions to Promises and apply currying to arguments
Last updated 7 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install zames 
SYNC missed versions from official npm registry.

Zames License NPM version Dependency Status Build Status Coverage Status

zames converts callback-based functions to Promises and apply currying to arguments.

zames = currify + promisify.

Install

npm i zames --save

API

zames(fn [,ctx])

  • fn - function
  • ctx - context

zames can take just a function:

const zames = require('zames');

const promise = zames((a, b, fn) => {
    fn(null, a + b);
});

const add = promise('hello ');

add('world').then((a) => {
    console.log(a);
    // output
    'hello world';
});

Or can be used with ctx as well:

const ctx = {
    error: 'hello',
    log: function(a, b, fn) {
        fn(this.error);
    }
}

const withContext = zames(ctx.log, ctx);

withContext(1, 2)
    .catch((e) => {
        console.error(e.message);
        // output
        'hello';
    });

Related

  • currify - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments.

  • fullstore - functional variables.

  • wraptile - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of 2 functions, each with a any count of arguments.

License

MIT

Current Tags

  • 3.0.0                                ...           latest (7 years ago)

9 Versions

  • 3.0.0                                ...           7 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           9 years ago
  • 1.1.3                                ...           9 years ago
  • 1.1.2                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 12
Today 0
This Week 0
This Month 11
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (9)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE