2019-02-16 11:45:22 -08:00
|
|
|
### uCOMmandIt Type Library
|
|
|
|
|
2020-03-16 10:24:22 -07:00
|
|
|
Extends the type checker Library
|
|
|
|
All includes some simple type casting including using uci to-boolean for boolean type casting.
|
|
|
|
|
|
|
|
See type checker api http://master.typechecker.bevry.surge.sh/docs/
|
|
|
|
|
2020-03-16 10:52:12 -07:00
|
|
|
extensions are
|
2020-03-16 10:24:22 -07:00
|
|
|
|
|
|
|
`.isPromise`
|
|
|
|
`.isBuffer`
|
|
|
|
|
|
|
|
TODO add
|
|
|
|
|
|
|
|
import isObservable from 'is-observable'
|
|
|
|
import isPromise from 'p-is-promise'
|
|
|
|
|
|
|
|
```
|
|
|
|
function isEmitter(emitter) {
|
|
|
|
if (!emitter) return false
|
|
|
|
let check = ['on','emit']
|
|
|
|
return check.reduce((acc,fn)=> acc && typeof emitter[fn] ==='function',true)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isAsync(fn) {
|
|
|
|
if (typeof fn !== 'function') return false
|
|
|
|
return (isPromise(fn) || fn.constructor.name === 'AsyncFunction')
|
|
|
|
}
|
|
|
|
```
|