@fantastic-utils/data-type
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@fantastic-utils/data-type

NPM version NPM downloads codecov

This is a library for get correct data type from javascript values. Why use this lib? As typeof have some limitations.

Quick Start

npm install @fantastic-utils/data-type
import { getDataType } from '@fantastic-utils/data-type';

getDataType(1); // return Number
getDataType('a'); // return String
getDataType({}); // return Object
getDataType([]); // return Array
getDataType(false); // return Boolean
getDataType(Symbol('a')); // return Symbol
getDataType(new WeakMap()); // return WeakMap
getDataType(new Map()); // return Map
getDataType(new Proxy({}, {})); // return Object
getDataType(new Proxy([], {})); // return Array
getDataType(new Promise(() => {})); // return Promise
getDataType(Promise.resolve(1)); // return Promise
getDataType(NaN); // return Number
getDataType(Infinity); // return Number
getDataType(() => {}); // return Function
getDataType(new Websocket('wss://example.com')); // return Websocket

// etc...

Development

$ npm install
$ npm run dev
$ npm run build

LICENSE

MIT

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @fantastic-utils/data-type

    Weekly Downloads

    9

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    6.55 kB

    Total Files

    7

    Last publish

    Collaborators

    • luckyzhou