validate-stringifiable.js 318 B

123456789101112
  1. "use strict";
  2. var isCallable = require("./is-callable");
  3. module.exports = function (stringifiable) {
  4. try {
  5. if (stringifiable && isCallable(stringifiable.toString)) return stringifiable.toString();
  6. return String(stringifiable);
  7. } catch (e) {
  8. throw new TypeError("Passed argument cannot be stringifed");
  9. }
  10. };