webview白屏的问题查找和修复
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
/**
* @Description: js变量类型判断
* @Author: MuYi086
* @Email: 1258947325@qq.com
* @Blog: https://github.com/MuYi086/blog
* @Date: 2021/04/11 12:30
*/
class VarType {
constructor () {
this.typeList = ['Null', 'Undefined', 'Object', 'Array', 'ArrayBuffer', 'String', 'Number', 'Boolean', 'Function', 'RegExp', 'Date', 'FormData', 'File', 'Blob', 'URLSearchParams', 'Set', 'WeakSet', 'Map', 'WeakMap']
this.init()
}
/**
* 判断变量类型
* @param {string} value
* @returns lowercase string
*/
type (value) {
const s = Object.prototype.toString.call(value)
return s.match(/\[object (.*?)\]/)[1].toLowerCase()
}
/**
* 增加判断类型数据方法
*/
init () {
this.typeList.forEach((t) => {
this['is' + t] = (o) => {
return this.type(o) === t.toLowerCase()
}
})
}
/**
* isBuffer
* @param {any} val
* @returns boolean
*/
isBuffer (val) {
return val !== null && !this.isUndefined(val) && val.constructor !== null && !this.isUndefined(val.constructor) && this.isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val)
}
/**
* isStream
* @param {any} val
* @returns boolean
*/
isStream (val) {
return this.isObject(val) && this.isFunction(val.pipe)
}
}
// 使用 varType["isNull"](null)等
module.exports = new VarType()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;/**
* @Description: js变量类型判断
* @Author: MuYi086
* @Email: 1258947325@qq.com
* @Blog: https://github.com/MuYi086/blog
* @Date: 2021/04/11 12:30
*/
class VarType {
private typeList: string[]
private static _instance: VarType | null = null
constructor() {
this.typeList = ['Null', 'Undefined', 'Object', 'Array', 'ArrayBuffer', 'String', 'Number', 'Boolean', 'Function', 'RegExp', 'Date', 'FormData', 'File', 'Blob', 'URLSearchParams', 'Set', 'WeakSet', 'Map', 'WeakMap']
this.init()
}
static get instance(): VarType {
if (!VarType._instance) {
VarType._instance = new VarType()
}
return VarType._instance
}
/**
* 判断变量类型
* @param {string} value
* @returns lowercase string
*/
private type (value: any): string {
const s = Object.prototype.toString.call(value)
return s.match(/\[object (.*?)\]/)[1].toLowerCase()
}
/**
* 增加判断类型数据方法
*/
private init(): void {
const self = this
this.typeList.forEach((t: string) => {
Object.defineProperty(VarType.prototype, `is${t}`, {
value: function (o: any) {
return self.type(o) === t.toLowerCase()
},
writable: true,
configurable: true
})
})
}
/**
* isBuffer
* @param {any} val
* @returns boolean
*/
static isBuffer(val: any): boolean {
return val !== null && (VarType as any).isUndefined(val) && val.constructor !== null && (VarType as any).isUndefined(val.constructor) && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val)
}
/**
* isStream
* @param {any} val
* @returns boolean
*/
static isStream(val: any): boolean {
return (VarType as any).isObject(val) && (VarType as any).isFunction(val.pipe)
}
}
// 使用 varType["isNull"](null)等
export const varType = VarType.instancevar s = Object.defineProperty;
var o = Object.getOwnPropertyDescriptor;
var c = Object.getOwnPropertyNames;
var u = Object.prototype.hasOwnProperty;
var p = (e, t) = >{
for (var n in t) s(e, n, {
get: t[n],
enumerable: !0
})
},
y = (e, t, n, i) = >{
if (t && typeof t == "object" || typeof t == "function") for (let r of c(t)) ! u.call(e, r) && r !== n && s(e, r, {
get: () = >t[r],
enumerable: !(i = o(t, r)) || i.enumerable
});
return e
};
var f = e = >y(s({},
"__esModule", {
value: !0
}), e);
var b = {};
p(b, {
varType: () = >l
});
module.exports = f(b);
var a = class e {
typeList;
static _instance = null;
constructor() {
this.typeList = ["Null", "Undefined", "Object", "Array", "ArrayBuffer", "String", "Number", "Boolean", "Function", "RegExp", "Date", "FormData", "File", "Blob", "URLSearchParams", "Set", "WeakSet", "Map", "WeakMap"],
this.init()
}
static get instance() {
return e._instance || (e._instance = new e),
e._instance
}
type(t) {
return Object.prototype.toString.call(t).match(/\[object (.*?)\]/)[1].toLowerCase()
}
init() {
let t = this;
this.typeList.forEach(n = >{
Object.defineProperty(e.prototype, `is$ {
n
}`, {
value: function(i) {
return t.type(i) === n.toLowerCase()
},
writable: !0,
configurable: !0
})
})
}
static isBuffer(t) {
return t !== null && e.isUndefined(t) && t.constructor !== null && e.isUndefined(t.constructor) && typeof t.constructor.isBuffer == "function" && t.constructor.isBuffer(t)
}
static isStream(t) {
return e.isObject(t) && e.isFunction(t.pipe)
}
},
l = a.instance;