tostring.js 262 B

1234567891011
  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. };