Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Type assertions aka less-broken `typeof`
JavaScript CSS Other
tree: 5722c0d4c0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

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(new Error('Ups! Something wrong...')) == 'error'

License

MIT

Something went wrong with that request. Please try again.