test.js 395 B

123456789101112
  1. var bufferFrom = require('./')
  2. var assert = require('assert')
  3. assert.equal(bufferFrom([1, 2, 3, 4]).toString('hex'), '01020304')
  4. var arr = new Uint8Array([1, 2, 3, 4])
  5. assert.equal(bufferFrom(arr.buffer, 1, 2).toString('hex'), '0203')
  6. assert.equal(bufferFrom('test', 'utf8').toString('hex'), '74657374')
  7. var buf = bufferFrom('test')
  8. assert.equal(bufferFrom(buf).toString('hex'), '74657374')