the-type
v0.1.0
Published
> Returns the type of a value
Downloads
1
Readme
the-type
Returns the type of a value
Detecting the type of a value in JavaScript can be frustrating. The typeof
operator can yield confusing results (for example typeof null === 'object'
). This package attempts to solve this by providing a more sensical type detection.
Installation
npm i the-type
Usage
import theType from 'the-type'
theType(42) // 'number'
theType('hello world') // 'string'
theType(() => {}) // 'function'
theType({}) // 'object'
theType([]) // 'array'
theType(null) // 'null'
theType(undefined) // 'undefined'
theType(Symbol()) // 'symbol'
Local Development
npm run build
or yarn build
Bundles the package to the dist
folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
npm test
or yarn test
Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
Contributing
This project is open to and encourages contributions! Feel free to discuss any bug fixes/features in the issues. If you wish to work on this project:
- Fork this project
- Create a branch (
git checkout -b new-branch
) - Commit your changes (
git commit -am 'add new feature'
) - Push to the branch (
git push origin new-branch
) - Submit a pull request!