@ahassani/type

0.0.1 • Public • Published

type

Type assertions aka less-broken typeof.

Example

var type = require('@ahassani/type');

var obj = new Date;
if (type(obj) == 'date') ...

API

type(new Date) == 'date'
type({}) == 'object'
type(null) == 'null'
type(undefined) == 'undefined'
type("hey") == 'string'
type(true) == 'boolean'
type(false) == 'boolean'
type(12) == 'number'
type(type) == 'function'
type(/asdf/) == 'regexp'
type((function(){ return arguments })()) == 'arguments'
type([]) == 'array'
type(document.createElement('div')) == 'element'
type(NaN) == 'nan'
type(new Error('Ups! Something wrong...')) == 'error'
type(new Buffer) == 'buffer'

Readme

Keywords

Package Sidebar

Install

npm i @ahassani/type

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

2.79 kB

Total Files

3

Last publish

Collaborators

  • a.hassani