Front end of the Slack clone application.

index.js 423B

123456789101112131415
  1. module.exports = toBuffer
  2. var makeBuffer = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from : bufferFrom
  3. function bufferFrom (buf, enc) {
  4. return new Buffer(buf, enc)
  5. }
  6. function toBuffer (buf, enc) {
  7. if (Buffer.isBuffer(buf)) return buf
  8. if (typeof buf === 'string') return makeBuffer(buf, enc)
  9. if (Array.isArray(buf)) return makeBuffer(buf)
  10. throw new Error('Input should be a buffer or a string')
  11. }