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.

index.js 423B

1234567891011121314
  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. }