Package Exports
- zames
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 (zames) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Zames

zames
converts callback-based functions to Promises and apply currying to arguments.
Install
npm i zames --save
API
zames(fn [,ctx])
fn
- functionctx
- 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