UNPKG

moltres-utils

Version:
40 lines (34 loc) 1.23 kB
"use strict"; require("core-js/modules/es6.object.define-property"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _objectToString = _interopRequireDefault(require("./objectToString")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them all as 'Object'. * * @function * @since v0.0.18 * @category lang * @param {*} value The value to test * @returns {string} * @example * * toType({}) //=> 'Object' * toType(1) //=> 'Number' * toType(false) //=> 'Boolean' * toType('s') //=> 'String' * toType(null) //=> 'Null' * toType([]) //=> 'Array' * toType(/[A-z]/) //=> 'RegExp' * toType(() => {}) //=> 'Function' * toType(undefined) //=> 'Undefined' */ var toType = function toType(value) { return value === null ? 'Null' : value === undefined ? 'Undefined' : (0, _objectToString.default)(value).slice(8, -1); }; var _default = toType; exports.default = _default; //# sourceMappingURL=toType.js.map