typeof
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/typeof package

1.0.0 • Public • Published

typeof

Small node.js module that dramatically extends functionality of native typeof

Inspired by Batman.js typeOf util

UPD: now it returns lowercased name of any javascript class. Thanks to @BallBearing for idea

Usage:

$ npm install typeof
var typeOf = require('typeof');
 
console.log(typeOf("a string"));
// -> "string"
 
console.log(typeOf([1, 2, 3, "array"]));
// -> "array"
 
console.log(typeOf(null));
// -> "null"
 
console.log(typeOf(new Buffer(0)));
// -> "buffer"
 
function MyClass() {
  this.is = "class constructor"  
}
console.log(typeOf(new MyClass));
// ->"myclass"

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    36,047
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    36,047
  • 0.9.1
    1
  • 0.9.0
    1

Package Sidebar

Install

npm i typeof

Weekly Downloads

36,049

Version

1.0.0

License

MIT

Last publish

Collaborators

  • codingfu