zam

zames

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

Showing:

Popularity

Downloads/wk

17.4K

GitHub Stars

3

Maintenance

Last Commit

2yrs ago

Contributors

1

Package

Dependencies

2

Size (min+gzip)

0.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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';
    });

  • 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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100