1.0.2 • Published 3 years ago

icat_checktype v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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,
  }