This package has been deprecated

Author message:

Deprecated in favor of 'fjl'. All 0.2X.X versions contain the 'typeOf' method.

fjl-typeof

1.0.0 • Public • Published

fjl-typeof

Strict typeof implementation. Gives you a value's type name.

Usage

typeOf(x)

Returns a value's "type" name; E.g. (value).constructor.name else for null returns Null; for undefined returns Undefined; for NaN returns 'NaN'; for every other value type returns their type's name (functionality includes the likes of Symbol all native javascript constructors and includes userland ones).

Params:

  • x - Some value to get type name of.

Returns:

A string representing the type's name; E.g., typeOf("hello") === 'String'

#####Examples:

typeOf('hello') === 'String'
typeOf(99) === 'Number'
typeOf(0 / 0) === 'NaN'
typeOf(Symbol('hello')) === 'Symbol'
typeOf(null) === 'Null'
typeOf(undefined) === 'Undefined'
etc..

Motivation

  • Javascript doesn't have a built-in, all-around type checker. This function allows one to build one.
  • Is a more robust alternative than using the native typeof since it gets type names of all native and userland types.
  • Very useful in-cases where many type checks are necessary (long logical (switch, if) control statement chains etc.).

Pre-requistes

Ecmascript 5+

Installation

  • npm install fjl-typeof or
  • yarn add fjl-typeof

License

BSD 3

Readme

Keywords

none

Package Sidebar

Install

npm i fjl-typeof

Weekly Downloads

8

Version

1.0.0

License

BSD-3-Clause

Last publish

Collaborators

  • elycruz