component-type
Cross-browser type assertions (less broken typeof)
Last updated 9 years ago by mattmueller .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install component-type 
SYNC missed versions from official npm registry.

type

Type assertions aka less-broken typeof.

Example

var type = require('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'

License

MIT

Current Tags

  • 1.2.1                                ...           latest (9 years ago)

3 Versions

  • 1.2.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.0                                ...           10 years ago

Copyright 2013 - present © cnpmjs.org | Home |