0.1.3 • Published 10 years ago

isval v0.1.3

Weekly downloads
516
License
MIT
Repository
github
Last release
10 years ago

isval

isval is a helper module that validates any given value. It overcomes common JavaScript issues with type checking, like NaN and null values.

Build Status

Example

var isval = require('isval');
var string = 'I am a string';

assert.ok(isval(string, 'string'));

Installation

Node

To install isval in a Node application use npm.

$ npm install isval

Browser

No tests available for the browser but you may try using it via webpack.

$ webpack index.js isval.js

Test

To run tests use npm.

$ npm install
$ npm test

Documentation

Basic Usage

The following types are available:

  • 'string'
  • 'number'
  • 'boolean'
  • 'function'
  • 'object'
  • 'array'
  • 'regex'
  • 'regexp'
  • 'date'
  • 'null'
  • 'undefined'
  • 'NaN'
  • 'arguments'
  • 'integer'
  • 'generator', (function *(){})()
  • 'generator*', function *() {}

Types can also be literal values:

  • String
  • Number
  • Boolean
  • Object
  • null
  • undefined
  • NaN

Instance Of

Passing a constructor function will check if the value is an instanceof of that "Class".

var buffer = new ArrayBuffer();
isval(buffer, ArrayBuffer);

Truthy Values

Passing no type will check for truthy values.

isval(1);
isval('true');

API

isval(<value>, type)

License

MIT

Copyright (c) 2014 Christopher Turner

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago