tostring.js 262 B

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