assertString.js 698 B

123456789
  1. 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); }
  2. export default function assertString(input) {
  3. var isString = typeof input === 'string' || input instanceof String;
  4. if (!isString) {
  5. var invalidType = _typeof(input);
  6. if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
  7. throw new TypeError("Expected a string but received a ".concat(invalidType));
  8. }
  9. }