https://github.com/danigb/hi-typeof
Generate isStr, isNum and other typeof functions
https://github.com/danigb/hi-typeof
Last synced: 4 months ago
JSON representation
Generate isStr, isNum and other typeof functions
- Host: GitHub
- URL: https://github.com/danigb/hi-typeof
- Owner: danigb
- License: mit
- Created: 2016-06-16T14:24:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-16T17:40:17.000Z (about 9 years ago)
- Last Synced: 2025-01-27T13:05:10.615Z (5 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hi-typeof [](https://www.npmjs.com/package/hi-typeof)
[](https://github.com/feross/standard) [](https://www.npmjs.com/package/hi-typeof)
Some sugar to the javascript `typeof` operator. Generate isStr, isNum and other typeof functions.
## Usage
```js
var is = require('hi-typeof')var isStr = is('string')
isStr('a string here') // => truevar isNum = is('number')
isNum(16) // => true
isNum('16') // => falsevar isFn = is('function')
isFn(isFn) // => true// Create inverse test
var isDef = is('undefined', false)
isDef(isDef) // => true
isDef(isDef.currentTime) // => false
```Basically, it's a function I use a lot and just makes the code clear and concise. It does not add any extra functionallity to the `typeof` operator.
## Source
This is the smallest module I've published (sorry for the npm package pollution), so here is the full source code:
```js
module.exports = function (t, r) {
var b = r === false
return function (o) { return (typeof o === t) !== b }
}
```## License
MIT License