0.0.2 • Published 8 years ago

better-type-of v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

better-type-of

A better typeof

install

npm install better-type-of

usage

import typeOf from 'better-type-of';

typeOf(null) === 'null';
typeOf(/test/) === 'reg exp';
typeOf(Promise.resolve()) === 'promise';
typeOf(function *() {}) === 'generator function';
typeOf(document) === 'html document';

why

Lots of libraries out there will check the type of a value and you can always call Object.prototype.toString yourself. This is different in that it's a simple function that returns more or less what you'd expect from typeof. Compare

Object.prototype.toString.call(document) === '[object HTMLDocument]';

typeOf(document) === 'html document';

see also

license

MIT

0.0.2

8 years ago

0.0.1

8 years ago