@pakal/is-type-of
v0.2.1
Published
Is Type Of is package from Pakal library
Downloads
58
Maintainers
Readme
@pakal/is-type-of
Is Type Of is package from Pakal library
Install
$ yarn add @pakal/is-type-of
Or
$ npm install --save @pakal/is-type-of
Use
Module
import {
default as isTypeOf
} from '@pakal/is-type-of';
Browser
<script src="https://unpkg.com/@pakal/is-type-of/bundle.umd.min.js"></script>
let {
isTypeOf
} = _;
Examples
isTypeOf('foo', 'string'); // => true
isTypeOf(null, 'null'); // => true
isTypeOf(Object(1), 'object'); // => true
isTypeOf(null, 'object'); // => false
isTypeOf(Object(true), 'boolean'); // => false
isTypeOf(v => v, 'object') // => false
isTypeOf(class {}, ['undefined', 'function']) // => true
isTypeOf({}, ['object', 'undefined']) // => true
isTypeOf(1, []) // => false
isTypeOf(null, ['undefined', 'number']) // => false
@pakal/is-type-of/assert
Module
import {
default as assertTypeOf
} from '@pakal/is-type-of/assert';
Browser
<script src="https://unpkg.com/@pakal/is-type-of/assert/bundle.umd.min.js"></script>
let {
assertTypeOf
} = _;
Examples
assertTypeOf(1, 'number'); // => 1
assertTypeOf(undefined, 'undefined'); // => undefined
assertTypeOf(Object('foo'), 'string'); // throw TypeError
assertTypeOf(null, 'object'); // throw TypeError
assertTypeOf(true, []); // throw TypeError
assertTypeOf({}, ['null']); // throw TypeError
assertTypeOf(function(){}, ['object', 'null', 'undefined']); // throw TypeError
assertTypeOf(Symbol('foo'), ['undefined', 'string', 'symbol']); // => Symbol('foo')
assertTypeOf({}, ['object', 'null']); // => {}
License
Copyright © Yisrael Eliev, Licensed under the MIT license.