safe-to-string.js 266 B

123456789101112
  1. "use strict";
  2. var isCallable = require("./object/is-callable");
  3. module.exports = function (value) {
  4. try {
  5. if (value && isCallable(value.toString)) return value.toString();
  6. return String(value);
  7. } catch (e) {
  8. return "<Non-coercible to string value>";
  9. }
  10. };