Detalhes do pacote

zames

coderaiser92.6kMIT3.0.0

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

curry, promise, currify, promisify

readme (leia-me)

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

changelog (log de mudanças)

2019.09.20, v3.0.0

feature:

  • (package) eslint v6.4.0
  • (package) currify v4.0.0
  • (zames) drop support of legacy
  • (package) nyc v14.0.0

2018.10.10, v2.0.1

feature:

  • (package) currify v3.0.0
  • (package) nyc v13.0.1
  • (package) eslint v5.6.0
  • (package) babel v7.0.0
  • (package) redrun v7.0.0
  • (package) nyc v12.0.2

2018.05.03, v2.0.0

feature:

  • (zames) increased arguments count to 8
  • (zames) rm browserify
  • (package) redrun v6.0.0
  • (package) buble v0.19.2
  • (package) browserify v16.0.0

2018.01.31, v1.1.3

feature:

  • (package) es6-promisify v6.0.0
  • (package) browserify v15.2.0
  • (package) buble v0.18.0
  • (package) buble v0.17.0
  • (package) coveralls v3.0.0
  • (package) buble v0.16.0
  • (package) minify v3.0.0
  • (package) nyc v11.0.2
  • (package) eslint v4.0.0
  • (package) browserify v14.0.0

2016.12.17, v1.1.2

feature:

  • (package) mkdirp: dependencies -> devDependencies
  • (package) buble v0.15.1
  • (package) nyc v10.0.0

2016.11.23, v1.1.1

feature:

  • (package) currify v2.0.0

2016.11.17, v1.1.0

feature:

  • (zames) add ctx
  • (npmignore) rm bower.json
  • (eslint) add

2016.11.16, v1.0.1

fix:

  • (zames) legacy
  • (zames) add .*

feature:

  • (package) keywords