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
- Host: GitHub
- URL: https://github.com/caiogondim/type-from.js
- Owner: caiogondim
- Created: 2018-04-14T23:55:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T01:42:30.000Z (about 7 years ago)
- Last Synced: 2025-02-25T04:47:06.519Z (3 months ago)
- Language: JavaScript
- Homepage: https://npm.im/type-from
- Size: 52.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)