UNPKG

@muyi086/var-type

Version:
2 lines (1 loc) 667 B
var e=class{constructor(){this.typeList=["Null","Undefined","Object","Array","ArrayBuffer","String","Number","Boolean","Function","RegExp","Date","FormData","File","Blob","URLSearchParams","Set","WeakSet","Map","WeakMap"],this.init()}type(t){return Object.prototype.toString.call(t).match(/\[object (.*?)\]/)[1].toLowerCase()}init(){this.typeList.forEach(t=>{this["is"+t]=r=>this.type(r)===t.toLowerCase()})}isBuffer(t){return t!==null&&!this.isUndefined(t)&&t.constructor!==null&&!this.isUndefined(t.constructor)&&this.isFunction(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}isStream(t){return this.isObject(t)&&this.isFunction(t.pipe)}};module.exports=new e;