tcheck

0.1.0 • Public • Published

node-tcheck

Lightweight type check library for JavaScript

Installation

$ npm install tcheck

How to include

    var tcheck = require('tcheck');

Examples

Verify if foo is of type String

    var foo = 'bar';
    console.log(tcheck(foo, String)); // Should output "true"

Multiple type checks

    var str1 = 'foo';
    var str2 = new String('bar');
    var num1 = 12345;
    var num2 = 12.34;
    var date = new Date();
    console.log(tcheck(str1, String, str2, String, num1, Number, num2, Number, date, Date)); // Should also output "true"

Using own classes

    function User(name, age) {
      this.name = name;
      this.age = age;
    }
    var userObj = new User('Joko van Klaas', 30);
    console.log(tcheck(userObj, User)); // Outputs "true"

Readme

Keywords

none

Package Sidebar

Install

npm i tcheck

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • muslim-idris