This package has been deprecated

Author message:

Development of this module has been stopped.

arg-types

0.0.10 • Public • Published

arg types Build Status js-standard-style

A very simple module to do runtime argument type checking of functions.

Usage

Installation:

Use yarn or npm:

$ [sudo] npm install --save arg-types

Example:

The very contrived example below would stop "33" being returned by the function.

var argTypes = require('./')
 
// define your function signature, the next line returns a function
// which expects an `arguments` object
var helloSignature = argTypes(['number', 'number', 'number'])
 
function hello (a, b, c) {
  helloSignature(arguments) // add this line as the first one in the target function
 
  return a + b + c
}
 
try {
  hello(1, 2, '3')
} catch (ex) {
  assert(ex.message === 'Expected "number" but got "string" at argument 3.')
}

Package Sidebar

Install

npm i arg-types

Weekly Downloads

0

Version

0.0.10

License

MIT

Last publish

Collaborators

  • roryrjb