How to use the wrap function from bytebuffer

Find comprehensive JavaScript bytebuffer.wrap code examples handpicked from public code repositorys.

513
514
515
516
517
518
519
520
521
522
	// This is an enqueued connection closure
	this._handleConnectionClose(conn);
	return;
}

let buf = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);

let rawEMsg = buf.readUint32();
let eMsg = rawEMsg & ~PROTO_MASK;
let isProtobuf = !!(rawEMsg & PROTO_MASK);
fork icon137
star icon643
watch icon0

+ 117 other calls in file

635
636
637
638
639
640
641
642
643
644
	// Standard zip
	let unzip = new AdmZip(data);
	return resolve(unzip.readFile(unzip.getEntries()[0]));
} else {
	// VZip
	data = ByteBuffer.wrap(data, ByteBuffer.LITTLE_ENDIAN);

	data.skip(2); // header
	if (String.fromCharCode(data.readByte()) != 'a') {
		return reject(new Error("Expected VZip version 'a'"));
fork icon137
star icon643
watch icon0

329
330
331
332
333
334
335
336
337
338
const onionRequestPayloadMetadata = {
  // destination: host,protocol,port,destination,method,target
  ephemeral_key: ephermalPubkeyHex,
}
const payloadStr = JSON.stringify(onionRequestPayloadMetadata)
const bufferJson = ByteBuffer.wrap(payloadStr, 'utf8')

// now calculate encrypted payload (finalDestOptions)
const rpcCall = {
  endpoint, // /room/some-room
fork icon6
star icon39
watch icon8

+ 15 other calls in file

38
39
40
41
42
43
44
45
46
47
48
49
}


// used for proxy requests
const DHEncrypt64 = async (symmetricKey, plainText) => {
  const ivAndCiphertext = await DHEncrypt(symmetricKey, plainText)
  return bb.wrap(ivAndCiphertext).toString('base64')
}


// used for tokens
const DHDecrypt64 = async (symmetricKey, cipherText64) => {
fork icon6
star icon39
watch icon8

+ 13 other calls in file

1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
    encoding = undefined;
}
var capacity = 0;
for (var i=0, k=buffers.length, length; i<k; ++i) {
    if (!ByteBuffer.isByteBuffer(buffers[i]))
        buffers[i] = ByteBuffer.wrap(buffers[i], encoding);
    length = buffers[i].limit - buffers[i].offset;
    if (length > 0) capacity += length;
}
if (capacity === 0)
fork icon0
star icon0
watch icon1

+ 14 other calls in file

45
46
47
48
49
50
51
52
53
54
		}
	}

	this.emit('debug', "Got " + (handler ? "handled" : "unhandled") + " GC message " + msgName + (isProtobuf ? " (protobuf)" : ""));
	if (handler) {
		handler.call(this, isProtobuf ? payload : ByteBuffer.wrap(payload, ByteBuffer.LITTLE_ENDIAN));
	}
});

this._steam.on('appLaunched', (appid) => {
fork icon0
star icon0
watch icon0