You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
272 B

4 years ago
  1. /*global module*/
  2. var Buffer = require('buffer').Buffer;
  3. module.exports = function toString(obj) {
  4. if (typeof obj === 'string')
  5. return obj;
  6. if (typeof obj === 'number' || Buffer.isBuffer(obj))
  7. return obj.toString();
  8. return JSON.stringify(obj);
  9. };