UNPKG

typedescriptor

Version:

typedescriptor identifies and describes types.

56 lines (55 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.typeOf = void 0; const isArray_1 = require("./isArray"); const isBoolean_1 = require("./isBoolean"); const defekt_1 = require("defekt"); const isFunction_1 = require("./isFunction"); const isMap_1 = require("./isMap"); const isNull_1 = require("./isNull"); const isNumber_1 = require("./isNumber"); const isObject_1 = require("./isObject"); const isSet_1 = require("./isSet"); const isString_1 = require("./isString"); const isSymbol_1 = require("./isSymbol"); const isUndefined_1 = require("./isUndefined"); const typeOf = function (value) { if ((0, isArray_1.isArray)(value)) { return 'array'; } if ((0, isBoolean_1.isBoolean)(value)) { return 'boolean'; } if ((0, defekt_1.isError)(value)) { return 'error'; } if ((0, isFunction_1.isFunction)(value)) { return 'function'; } if ((0, isMap_1.isMap)(value)) { return 'map'; } if ((0, isNull_1.isNull)(value)) { return 'null'; } if ((0, isNumber_1.isNumber)(value)) { return 'number'; } if ((0, isSet_1.isSet)(value)) { return 'set'; } if ((0, isString_1.isString)(value)) { return 'string'; } if ((0, isSymbol_1.isSymbol)(value)) { return 'symbol'; } if ((0, isUndefined_1.isUndefined)(value)) { return 'undefined'; } if ((0, isObject_1.isObject)(value)) { return 'object'; } throw new Error('This should not have happened! Did you invent a new scalar type?'); }; exports.typeOf = typeOf;