Skip to content

gummesson/type-assertion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

type-assertion

NPM version License Build status

Assert the type of a value.

Installation

npm install type-assertion

Usage

var assert = require('type-assertion')

assert({}, 'object')
assert([], 'object')  //=> TypeError: expected object
assert('ok', 'value')
assert('', 'value')   //=> TypeError: expected value

API

assert(value, expected)

Assert that value has the type of expected (aliased to assert.type).

Why?

To provide a simple way to assert types with a small footprint. Node.js' assert module is nice, but it's a bit too big when it comes to using it on the front-end.

License

MIT

About

Assert the type of a value.

Resources

License

Stars

Watchers

Forks

Packages

No packages published