This package has been deprecated

Author message:

This library has been deprecated

checkt

1.1.5 • Public • Published

checkt

Build Status Dependency Status devDependency Status

What is it?

checkt is a small library for safe (chainable) type checks written in CoffeeScript and usable in any JavaScript environment.

Currently supported are:

  • Browser
  • CommonJS environments (Node.js)

The checkt library exposes the checkt function. (An alias is the check object, which has exactly the same functionality.)

Browser
Embed js/checkt.js in your HTML file for development purposes and js/checkt.min.js for production use.

Node.js
Either use npm with
npm install checkt
or add checkt to to the package.json of your project.

Usage

JavaScript

// Method chaining examples
check('test').not.string(function() {
 console.log('not a string');
}).otherwise(function() {
 console.log('Logically, should be a string');
}).number(function(v) {
 console.log("its a number with value: " + v);
});
 
// Instead of using method chaing, you can also use
// a plain object with the type as the key and the value is the callback function
check({}, {
  object: function() {
   console.log('Is an object');
  },
  number: function() {
   console.log('Is a number');
  }
});
 
// Multiple keys seperated by a comma also work, just make sure the key is
// written as a string
check('test', {
  'string, number': function() {
   console.log('Either string or number');
  }
});

CoffeeScript

# Method chaining examples 
check('test')
  .not.string(-> console.log 'not a string')
  .else(-> console.log 'Logically, should be a string')
  .number((v) -> console.log("its a number with value: #{v}"))
 
# Instead of using method chaing, you can also use 
# a plain object with the type as the key and the value is the callback function 
check {},
  object: -> console.log 'Is an object'
  number: -> console.log 'Is a number'
 
# Multiple keys seperated by a comma also work, just make sure the key is 
# written as a string 
check 'test',
  'string, number': -> console.log 'Either string or number'

License

checkt is public domain. See UNLICENSE.md for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i checkt

Weekly Downloads

1

Version

1.1.5

License

Public domain

Last publish

Collaborators

  • stoney