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

varta

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

varta

Guard your arguments. Verify and throw error if they do not meet your contract

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

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

varta

Guard your arguments. Verify and throw error if they do not meet your contract

build status

usage

var guard = require('varta');

function log(logger) {
  // this line will throw exception if logger instance is null or doesn't have
  // a method called `log`:
  guard(logger).has('log');
}

You can also expect multiple properties from an object:

var guard = require('varta');

function log(logger) {
  // this line will throw exception if logger instance is null or doesn't have
  // all three methods: `warn`, `info`, and `debug`
  guard(logger).has('warn', 'info', 'debug');
}

You can save expectations and reuse them in the code:

var verify = require('varta').has('warn', 'info', 'debug');

function log(logger) {
  // Our expectations are saved above. If the logger does not have all three
  // methods (`warn`, `info`, and `debug`) the code will throw an exception
  verify(logger);
}

why?

Failing early is very helpful technique when it comes to maintaining large code bases. If you fail as early as possible you will know exactly where something went wrong, instead of debugging a cryptic error message down the stack.

install

With npm do:

npm install varta

license

MIT

Keywords

FAQs

Package last updated on 12 Jan 2015

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