toString.js 791 B

12345678910111213141516171819202122
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  6. exports.default = toString;
  7. function toString(input) {
  8. if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && input !== null) {
  9. if (typeof input.toString === 'function') {
  10. input = input.toString();
  11. } else {
  12. input = '[object Object]';
  13. }
  14. } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
  15. input = '';
  16. }
  17. return String(input);
  18. }
  19. module.exports = exports['default'];