(value: unknown)
| 57 | } |
| 58 | |
| 59 | export function getObjectType(value: unknown): string { |
| 60 | const simple = typeof value; |
| 61 | |
| 62 | if (['string', 'number', 'boolean', 'bigint'].includes(simple)) { |
| 63 | return simple; |
| 64 | } |
| 65 | |
| 66 | const objectType = Object.prototype.toString.call(value); |
| 67 | const type = objectType.match(/\[object (\w+)]/)![1]; |
| 68 | |
| 69 | if (type === 'Uint8Array') { |
| 70 | return 'Buffer'; |
| 71 | } |
| 72 | |
| 73 | return ['Date', 'Buffer', 'RegExp'].includes(type) ? type : type.toLowerCase(); |
| 74 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…