@pakal/kind-of
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@pakal/kind-of

Source Code Version MIT License Bundle Size TypeScript

Kind Of is package from Pakal library

Install

$ yarn add @pakal/kind-of

Or

$ npm install --save @pakal/kind-of

Use

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.

Package Sidebar

Install

npm i @pakal/kind-of

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

40.4 kB

Total Files

15

Last publish

Collaborators

  • yisraelx