Socket
Socket
Sign inDemoInstall

zames

Package Overview
Dependencies
2
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    zames

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


Version published
Maintainers
1
Install size
22.8 kB
Created

Readme

Source

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

Keywords

FAQs

Last updated on 20 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc