better-typeof

2.0.0 • Public • Published

What

better-typeof is a single JavaScript function that returns the type of a value. This is mainly a learning exercise. You should probably use kind-of instead.

Why

The native JavaScript typeof operator is drunk and will shout "object" at almost any value you give it.

typeof {}; // object
typeof /a/; // object
typeof null; // object
typeof []; // object
typeof new String('foo'); // object

Installation

npm install --save better-typeof

Usage

const betterTypeof = require('better-typeof');
 
betterTypeof({}); // object
betterTypeof(/a/); // regexp
betterTypeof(null); // null
betterTypeof([]); // array
betterTypeof(new String('foo')); // string

Readme

Keywords

Package Sidebar

Install

npm i better-typeof

Weekly Downloads

0

Version

2.0.0

License

ISC

Last publish

Collaborators

  • dlevs