writeInt64(value) { this.ensureAvailable(INT64_SIZE) const longValue = Long.fromValue(value) this.buf.writeInt32BE(longValue.getHighBits(), this.offset) this.buf.writeInt32BE(longValue.getLowBits(), this.offset + INT32_SIZE) this.offset += INT64_SIZE return this }
writeInt32(value) { this.ensureAvailable(INT32_SIZE) this.buf.writeInt32BE(value, this.offset) this.offset += INT32_SIZE return this }
header.writeInt32BE(data.length + HEADER_SIZE, 1); header.writeInt8(type, 5); const crc = header[1] ^ header[2] ^ header[3] ^ header[4] ^ header[5];
const calculatedCrc = crc(buffer.slice(0, payload.length + 16)) & 0xFFFFFFFF; buffer.writeInt32BE(calculatedCrc, payload.length + 16); buffer.writeUInt32BE(0x0000AA55, payload.length + 20);
const encodeFrame = (frame) => { if (frame.payload.length + 1 > MAX_PACKET_SIZE) { throw new exceptions.RequestPayloadTooLargeException(); } const buf = Buffer.alloc(HEADER_SIZE_BYTES); buf.writeInt32BE(frame.payload.length + 1, 0); buf.writeInt8(frame.operation.asMap(), LENGTH_FIELD_SIZE_BYTES); return { header: buf, payload: frame.payload }; }
client.connect(3001, '127.0.0.1', () => { console.log('Connected'); const buffer = Buffer.alloc(6); buffer.writeInt32BE(6, 0); buffer.writeInt16BE(1525, 4); client.write(buffer); });
/** * Write an integer to the source buffer. * * @param value data to write */ writeInt(value) { const buf = Buffer.alloc(4); buf.writeInt32BE(value); this.write(buf); }
// not secure for node 0.4 [0, 4, 8].forEach(function(i) { rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i); });
this[$file].write(ofs, data).then(function () { header.writeInt32BE(next, OFS_HEAD, SIZEOF_INT); return _this2[$file].write(OFS_HEAD, header, OFS_HEAD, SIZEOF_INT); }).then(function () { return current; })
function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) }
var encode = function (data, seq) { var buf = new Buffer(8); buf.writeInt32BE(data.num, 0); buf.writeInt32BE(seq, 4); return buf; }
const intToBuffer = (i, length = 4) => { const buf = Buffer.alloc(length); if (length === 4) { buf.writeInt32BE(i, 0); } else if (length === 1) { buf.writeInt8(i, 0); } else { throw new Error('Illegal value specified for intToBuffer length. Must be 1 or 4.'); } return buf; }
function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) }
function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) }
function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) }