Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 18x 642x 3x 3x 3x 3x 3x 3x 13x 3x 3x 4x 3x 3x 3x 3x 79x 3x 237x 145x 92x 92x | const isType = <T>(type: string) => (obj: unknown): obj is T => obj != null && Object.prototype.toString.call(obj) === `[object ${type}]` export const isFn = isType<(...args: any[]) => any>('Function') export const isArr = Array.isArray || isType<unknown[]>('Array') export const isPlainObj = isType<object>('Object') export const isStr = isType<string>('String') export const isBool = isType<boolean>('Boolean') export const isNum = isType<number>('Number') export const isObj = (val: unknown): val is object => typeof val === 'object' export const isRegExp = isType<RegExp>('RegExp') export const isNumberLike = (t: any) => { return isNum(t) || /^(\d+)(\.\d+)?$/.test(t) } const isArray = isArr const keyList = Object.keys const hasProp = Object.prototype.hasOwnProperty export const toArray = <T>(val: T | T[]): T[] => Array.isArray(val) ? val : val !== undefined ? [val] : [] export const isEqual = (a: any, b: any) => { if (a === b) { return true } Iif (a && b && typeof a === 'object' && typeof b === 'object') { const arrA = isArray(a) const arrB = isArray(b) let i let length let key if (arrA && arrB) { length = a.length if (length !== b.length) { return false } for (i = length; i-- !== 0; ) { if (!isEqual(a[i], b[i])) { return false } } return true } if (arrA !== arrB) { return false } const keys = keyList(a) length = keys.length if (length !== keyList(b).length) { return false } for (i = length; i-- !== 0; ) { if (!hasProp.call(b, keys[i])) { return false } } for (i = length; i-- !== 0; ) { key = keys[i] if (!isEqual(a[key], b[key])) { return false } } return true } return a !== a && b !== b } |