kind-of
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
"Kind-of" is a high-performing npm package meticulously developed to get the fundamental type of any value in JavaScript. This versatile package can effectively distinguish between nuanced data types like 'null', 'undefined', 'boolean', 'buffer', 'number', 'string', 'arguments', 'object', 'array', 'regexp', 'date', 'error', 'function', ' generatorfunction', etc. It achieves the task more consistently and efficiently than other comparable libraries.
To use "kind-of", start by installing it via npm or bower with the following commands:
$ npm install --save kind-of
or
$ bower install kind-of --save
Once installed, you require it at the top of your file and use the exported function to get the type of any value.
var kindOf = require('kind-of');
console.log(kindOf(undefined)); // 'undefined'
console.log(kindOf(null)); // 'null'
console.log(kindOf(true)); // 'boolean'
console.log(kindOf(new Buffer(''))); // 'buffer'
console.log(kindOf(42)); // 'number'
console.log(kindOf('str')); // 'string'
console.log(kindOf(arguments)); // 'arguments'
console.log(kindOf({})); // 'object'
console.log(kindOf(new Date())); // 'date'
console.log(kindOf(/foo/)); // 'regexp'
console.log(kindOf(new Error('error'))); // 'error'
console.log(kindOf(function () {})); // 'function'
console.log(kindOf(Symbol('str'))); // 'symbol'
// and so on for other types...
Turns out the kind-of package is very easy to use, providing an efficient way to acquire the native type of values.
The official documentation for the "kind-of" package can be found on its GitHub repository: https://github.com/jonschlinkert/kind-of. This includes usage, installation details, benchmarks, optimizations and more. Remember, the key to mastering the usage of the "kind-of" package is hands-on coding and understanding the fundamental JavaScript types.