toString.js 895 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = toString;
  6. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7. function toString(input) {
  8. if (_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;
  20. module.exports.default = exports.default;