TypeDetector 
A class that holds a few simple predicate functions for detecting the native type of input.
Installation
Simply do: npm install @wessberg/typedetector
.
Usage
const typeDetector = new TypeDetector();
if (typeDetector.isFunction(something)) {
something(arg);
}
const set1 = new Set([1, 2, 3]);
const set2 = new Set([3, 2, 1]);
const set3 = set1;
typeDetector.isEqual(set1, set2);
typeDetector.isEqual(set1, set3);
The library only covers a few of the built-in types since instanceof
checks covers the rest.
But, for things such as strings
, numbers
and booleans
, the predicates will be truthy if
their object wrapper types is also used, e.g.:
typeDetector.isNumber(new Number(2))
Changelog:
v1.0.1:
- A few updates in the README.
v1.0.0:
- First release. Contains a few methods for things that traditional
instanceof
checks doesn't cover.