@pakal/kind-of
v0.2.1
Published
Kind Of is package from Pakal library
Maintainers
Readme
@pakal/kind-of
Kind Of is package from Pakal library
Install
$ yarn add @pakal/kind-ofOr
$ npm install --save @pakal/kind-ofUse
Module
import {
default as kindOf
} from '@pakal/kind-of';Browser
<script src="https://unpkg.com/@pakal/kind-of/bundle.umd.min.js"></script>let {
kindOf
} = _;Examples
kindOf(null); // => 'null'
kindOf(class {}); // => 'function'
kindOf(NaN); // => 'number'
kindOf(Object('foo')); // => 'string'
kindOf(String.prototype); // => 'object'
kindOf(Object.create(v => v)); // => 'object'
kindOf(Object.freeze({[Symbol.toStringTag]: 'Number'})); // => 'object'
// In env that not have native support.
let fooSym = Symbol('foo');
typeof fooSym; // => 'object'
kindOf(fooSym); // => 'symbol'
let bigNum = BigInt(1);
typeof bigNum; // => 'object'
kindOf(bigNum); // => 'bigint' let iframe = document.createElement('iframe');
document.body.appendChild(iframe);
let {String: IFrameString} = iframe.contentWindow;
kindOf(new IFrameString('foo')); // => 'string'Note: if Symbol or BigInt is not native (polyfill), the kind will base on Symbol.toStringTag property,
if value not has Symbol.toStringTag property it's will be returns that the kind is 'object'.
License
Copyright © Yisrael Eliev, Licensed under the MIT license.
