Esempio n. 1
0
function toString(buf, enc) {
  if(null == enc) return buf
  if('hex' == enc)
    return toHex(buf)
  if('binary' == enc)
    return toBinary(buf)
  return bopsToString(buf, enc)
}
Esempio n. 2
0
    104, 101, 108, 108,
    111, 32, 116, 104,
    101, 114, 101, 46
  ])

var FOOBARBAZ = new Uint8Array([
    102, 111, 111,
    98, 97, 114,
    98, 97, 112
  ])

var FOO = toBuffer('foo')
var BAR = toBuffer('bar')
var BAZ = toBuffer('baz')

var FOO64 = to(FOO, 'base64')
var BAR64 = to(BAR, 'base64')
var BAZ64 = to(BAZ, 'base64')
var FOOx = u.toHex('foo')
var BARx = u.toHex('bar')
var BAZx = u.toHex('baz')

tape('hello there, ascii', function (t) {
  var expected = HELLOTHERE
  var actual = new Uint8Array(12)

  write(actual, 'hello there.', 'ascii', 0, 0, 12)

  console.log(hexpp(actual.buffer))
  console.log(hexpp(expected.buffer))