1.0.2 • Published 6 years ago
checkis v1.0.2
checkis
My attempts to make this language a little more usable.
In Javascript, everything is and mostly is identified as an object. Doesn't necessarily mean they all behave the same way. This takes out some of the ambiguity of it. If typechecking is a matter of checking the value of strings, may as well expand upon that a little.
The contents of this library fall into this small but arguably useful little class.
Contents
- checkis.def = p => return true if p doesn't equal undefined.
- checkis.null = p => return true if p doesn't equal null
- checkis.array = p => return true if p is an array.
- checkis.bool = p => return true if p is a boolean (which may equal true or false)
- checkis.num = p => return true if p is a number (float or integer).
- checkis.str = p => return true if p is a string.
- checkis.date = p => return true if p is a date.
- checkis.func = p => return true if p is a function.
- checkis.buffer = p => return true if p is a buffer.
- checkis.regex = p => return true if p is a regex object.
- checkis.obj = p => return true if p is an object that isn't any of the above.
- checkis.what = p => return null, undefined or a text string with the determined type from the above list.
const is = require('checkis')
console.log("Boolean:", is.bool(true), "Number:", is.bool(1))