An open API service indexing awesome lists of open source software.

https://github.com/caiogondim/type-from.js

Get type from given argument
https://github.com/caiogondim/type-from.js

Last synced: 3 months ago
JSON representation

Get type from given argument

Awesome Lists containing this project

README

        

# type-from

Get type from given argument.

## Installation

```console
npm install --save type-from
```

## Usage

```js
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](https://caiogondim.com)  · 
GitHub [@caiogondim](https://github.com/caiogondim)  · 
Twitter [@caio_gondim](https://twitter.com/caio_gondim)