Package Exports
- realtypeof
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (realtypeof) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
realtypeof
This is a very simple and light package to get the real type of values.
Installation
$ npm install realtypeof
Usage
const realTypeOf = require('realtypeof');
realTypeOf(45); // 'number'
realTypeOf('hello'); // 'string'
realTypeOf(true); // 'boolean'
realTypeOf(null); // 'null'
realTypeOf(undefined); // 'undefined'
realTypeOf(Symbol()); // 'symbol'
realTypeOf([]); // 'array'
realTypeOf(() => {}); // 'function'
realTypeOf({}); // 'object'
realTypeOf(new Map()); // 'map'
realTypeOf(new Set()); // 'set'
realTypeOf(new WeakMap()); // 'weakmap'
realTypeOf(new WeakSet()); // 'weakset'
The type of returned value is always string
You can also check the type of value whether it is a particular type:
realTypeOf.isNumber(45); // true
realTypeOf.isString('hello'); // true
realTypeOf.isBoolean(true); // true
realTypeOf.isNull(null); // true
realTypeOf.isUndefined(undefined); // true
realTypeOf.isSymbol(Symbol()); // true
realTypeOf.isArray([]); // true
realTypeOf.isFunction(() => {}); // true
realTypeOf.isObject({}); // true
realTypeOf.isMap(new Map()); // true
realTypeOf.isSet(new Set()); // true
realTypeOf.isWeakMap(new WeakMap()); // true
realTypeOf.isWeakSet(new WeakSet()); // true
The type of returned value of these methods is always boolean