typehound
v0.1.6
Published
Find the exact type of an input.
Downloads
4
Readme
Typehound
Typehound is a simple type checking tool that lets you get the exact JavaScript type of a variable or input. Typehound takes a specified value as an input returns one of the six defined JavaScript types (string, number, boolean, array, object, symbol, null, or undefined).
Currently, Typehound only returns the type of the specified value but future releases will offer a verbose version with more information available about the provided input.
Typehound also has a browser based implementation option available. See the installation section for more details.
Installation
To install Typehound, simply use the npm install command.
$ npm install --save typehound
or, if you want to use typehound in the browser, import the browser file from the node_modules folder.
import typehound from './node_modules/typehound/browser.js';
Example
To use Typehound, simply require the module and use that to start checking values.
const typehound = require('typehound');
typehound('Hello World!');
// => 'string'
const check = [ 5, 'JavaScript', { hello: 'world' }];
typehound(check);
// => 'array'
To use Typehound in the browser simply replace the require with the import statement as specified in the installation statement.
import typehound from './node_modules/typehound/browser.js';
typehound('Hello World!');
// => 'string'
const check = [ 5, 'JavaScript', { hello: 'world' }];
typehound(check);
// => 'array'
Running Tests
To run the currently available Typehound tests, simply use the command below.
$ npm test
License
MIT No Attribution