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 | 1044x 22x 1135x 1134x 1134x 2x 1132x 60x 1072x 3x 1069x 3x 1066x 4x 1062x 3x 1059x 3x 1056x 5x 1051x 7x 1044x 7x 1037x 1037x 22x | import { TypeString, TypeTrue, TypeNull, TypeFalse, TypeFloat, TypeBigint, TypeInt, TypeDate, TypeUndefined, TypeNan, TypeUrl, } from '../types'; export const isFloat = (n: number) => (Number(n) === n && n % 1 !== 0) || isNaN(n); interface ValueProps { value: unknown; keyName: string | number; } export const Value = (props: ValueProps) => { const { value, keyName } = props; const reset = { keyName }; if (value instanceof URL) { return <TypeUrl {...reset}>{value}</TypeUrl>; } if (typeof value === 'string') { return <TypeString {...reset}>{value}</TypeString>; } if (value === true) { return <TypeTrue {...reset}>{value}</TypeTrue>; } if (value === false) { return <TypeFalse {...reset}>{value}</TypeFalse>; } if (value === null) { return <TypeNull {...reset}>{value}</TypeNull>; } if (value === undefined) { return <TypeUndefined {...reset}>{value}</TypeUndefined>; } if (value instanceof Date) { return <TypeDate {...reset}>{value}</TypeDate>; } if (typeof value === 'number' && isNaN(value)) { return <TypeNan {...reset}>{value}</TypeNan>; } else if (typeof value === 'number' && isFloat(value)) { return <TypeFloat {...reset}>{value}</TypeFloat>; } else if (typeof value === 'bigint') { return <TypeBigint {...reset}>{value}</TypeBigint>; } else Eif (typeof value === 'number') { return <TypeInt {...reset}>{value}</TypeInt>; } return null; }; Value.displayName = 'JVR.Value'; |