1.1.0 • Published 8 years ago
chkjs v1.1.0
check.js
A simple type checker for JavaScript
Usage
Check if value is a string.
let value = 'This is a string.';
check(value, String);Check if value is a list of strings.
let value = ['a', 'b', 'c'];
check(value, [String]);Check if value is a string, or null.
let value = 'string';
check(value, String, null);Check if value is an object with key id with type string.
let value = {
id: '0af390f0-abb6-4ef6-b9af-6287e6aab172'
};
check(value, {id: String});Please have a look at the tests to see more examples.
Credit
Forked from: Martijn de Haan https://github.com/martijndeh/check