diff options
Diffstat (limited to 'node_modules/es5-ext/object/validate-stringifiable.js')
-rw-r--r-- | node_modules/es5-ext/object/validate-stringifiable.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/node_modules/es5-ext/object/validate-stringifiable.js b/node_modules/es5-ext/object/validate-stringifiable.js new file mode 100644 index 000000000..2b1f12714 --- /dev/null +++ b/node_modules/es5-ext/object/validate-stringifiable.js @@ -0,0 +1,12 @@ +"use strict"; + +var isCallable = require("./is-callable"); + +module.exports = function (stringifiable) { + try { + if (stringifiable && isCallable(stringifiable.toString)) return stringifiable.toString(); + return String(stringifiable); + } catch (e) { + throw new TypeError("Passed argument cannot be stringifed"); + } +}; |