type-from
v1.0.1
Published
Get type from given argument
Downloads
14
Readme
type-from
Get type from given argument.
Installation
npm install --save type-from
Usage
typeFrom({}) // => 'object'
typeFrom([]) // => 'array'
typeFrom(1) // => 'number'
typeFrom('lorem') // => 'string'
typeFrom(() => {})) // => 'function'
typeFrom(Symbol('lorem')) // => 'symbol'
typeFrom(true) // => 'boolean'
typeFrom(null) // => 'null'
typeFrom(undefined) // => 'undefined'
typeFrom(/.*/) // => 'regexp'
typeFrom(new Date) // => 'date'
typeFrom(new Error) // => 'error'
typeFrom(new Uint8Array) // => 'uint'
typeFrom(new Int8Array) // => 'int'
typeFrom(new Float32Array) // => 'float'
typeFrom(new Map) // => 'map'
typeFrom(new Set) // => 'set'
typeFrom(new WeakMap) // => 'weakmap'
typeFrom(new WeakSet) // => 'weakset'
typeFrom(new Promise(() => {})) // => 'promise'
typeFrom(function* () {}) // => 'generatorfunction'
function foo() {
typeFrom(arguments) // => 'arguments'
}
caiogondim.com · GitHub @caiogondim · Twitter @caio_gondim