toString.js 689 B

12345678910111213
  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 toString(input) {
  3. if (_typeof(input) === 'object' && input !== null) {
  4. if (typeof input.toString === 'function') {
  5. input = input.toString();
  6. } else {
  7. input = '[object Object]';
  8. }
  9. } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
  10. input = '';
  11. }
  12. return String(input);
  13. }