icat_checktype
v1.0.2
Published
a tool help for checking type of function's params.
Downloads
3
Readme
How to use
let checkType = require("icat_checktype")
let user = function(name,age,sayFn,okBoolean){
//Here use checkType
checkType(
arguments //Array, params
,["string",["string","number","undefined"], //string or number or undefined
,"function?" //function or undefined
,"boolean"] //Array, wishing type
,"user" //String, name of function
)
//Attention!!! Because of Object.prototype.toString, class is function.
return {
name:name,
age:age || "I don't know.",
say:sayFn || function(){return "Hello, my name is "+this.name },
ok:okBoolean,
}