safe-to-string.js 407 B

123456789101112131415161718192021
  1. /* global Symbol */
  2. "use strict";
  3. module.exports = function (t, a) {
  4. a(t(), "undefined");
  5. a(t(null), "null");
  6. a(t(10), "10");
  7. a(t("str"), "str");
  8. a(
  9. t({
  10. toString: function () {
  11. return "miszka";
  12. }
  13. }),
  14. "miszka"
  15. );
  16. // eslint-disable-next-line symbol-description
  17. if (typeof Symbol === "function") a(t(Symbol()), "Symbol()");
  18. a(t(Object.create(null)), "<non-stringifiable value>");
  19. };