Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 10, 2024 via pnpm

type-detect 4.0.8

Improved typeof detection for node.js and the browser.
Package summary
Share
0
issues
1
license
1
MIT
Package created
14 Aug 2013
Version published
1 Feb 2018
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
type-detect@4.0.8
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of type-detect 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does type-detect do?

Type-detect is a highly useful npm package that provides improved type detection features for both Node.js and browsers. It returns a string representation of an object's type, delivering better specificity than native 'typeof' statements. Not only does it overcome the common problem of 'typeof' only specifying primitive values, with all other types falling under the vague "object" category, but it also addresses the speed and consistency issues associated with using Object.prototype.toString(). Through a custom code, type-detect improves speed checks upto 20-30x for some values and ensures consistency across JS and DOM objects.

How do you use type-detect?

Incorporating type-detect into your project is simple and convenient whether you are working in Node.js or within a browser. If you are operating on Node.js, type-detect can be downloaded from npm. Simply type $ npm install type-detect in your command prompt. For browser usage, the process is just as straightforward. Install via npm and utilize the type-detect.js file found within the download. An example usage:

<script src="./node_modules/type-detect/type-detect.js"></script>

After installation, type-detect can be incorporated into the code. Here are a few usage examples:

var type = require('type-detect');

assert(type([]) === 'Array');
assert(type(/a-z/gi) === 'RegExp');
assert(type(function () {}) === 'function');
assert(type(undefined) === 'undefined');
assert(type(null) === 'null');
assert(type({}) === 'Object');
assert(type(new Map()) === 'Map');
assert(type(new WeakMap()) === 'WeakMap');
assert(type(Symbol()) === 'symbol');

Where are the type-detect docs?

The documentation of type-detect is accessible on the official Github page of the package: chaijs/type-detect. The documentation includes all the necessary information about the usage and features of the package, to ensure smooth integration into projects.