assertString.js 871 B

1234567891011121314151617
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = assertString;
  6. function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
  7. function assertString(input) {
  8. var isString = typeof input === 'string' || input instanceof String;
  9. if (!isString) {
  10. var invalidType = _typeof(input);
  11. if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
  12. throw new TypeError("Expected a string but received a ".concat(invalidType));
  13. }
  14. }
  15. module.exports = exports.default;
  16. module.exports.default = exports.default;