Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rho-cc-node-style-callback

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rho-cc-node-style-callback

Create rho-contracts for Node-style callbacks

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

rho-cc-node-style-callback

Create rho-contracts for Node-style callbacks.

Usage

You must use the Body Labs package, rho-contracts-fork:

  "dependencies": {
    "rho-contracts-fork": "^1.3.0"
  }

Use this module to create contracts for a Node-style callbacks. The returned contracts accept functions whose first argument satisfies some error contract, and the other arguments are specified the same way as c.fun.

In the Node-style callback convention, any non-null non-undefined value for the first argument indicates an error. When an error is indicated, the other arguments must not be present, else a contract error is raised.

As a special case, invoking a callback with no arguments will invoke the wrapped function with one argument set to undefined.

Calling withError on the returned contract changes the type of the error argument to the contract specified.

The main entry point of this module is withDefaultError, which sets the expected error contract, like this:


var c = require('rho-contracts-fork');

var cc = {};

cc.callback = require('rho-cc-node-style-callback').withDefaultError(c.error)
cc.countCallback = cc.callback({ result: c.number })

Installation

npm install rho-contracts-fork rho-cc-node-style-callback

Contribute

Pull requests welcome!

Support

If you are having issues, please let us know.

License

The project is licensed under the Mozilla Public License Version 2.0.

FAQs

Package last updated on 12 Jul 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc