rambda
Version:
Lightweight and faster alternative to Ramda with included TS definitions
14 lines (13 loc) • 321 B
JavaScript
export function type(input) {
if (input === null) {
return 'Null'
}
if (input === undefined) {
return 'Undefined'
}
if (Number.isNaN(input)) {
return 'NaN'
}
const typeResult = Object.prototype.toString.call(input).slice(8, -1)
return typeResult === 'AsyncFunction' ? 'Promise' : typeResult
}