Comparing version 4.0.5 to 4.0.6
let BUFFER = Buffer.allocUnsafe(1024); | ||
// https://github.com/nodejs/node/issues/26607 | ||
// let BUFFER = Buffer.allocUnsafe(1024); | ||
// function send (message) { | ||
// let bytelength = BUFFER.write(message, 4, "utf8") + 4; | ||
// if (bytelength > BUFFER.length - 8) { | ||
// bytelength = Buffer.byteLength(message, "utf8") + 4; | ||
// BUFFER = Buffer.allocUnsafe(bytelength + 8); | ||
// BUFFER.write(message, 4, "utf8"); | ||
// } | ||
// BUFFER.writeUInt32LE(bytelength, 0); | ||
// this.write(BUFFER.slice(0, bytelength)); | ||
// }; | ||
@@ -12,14 +23,10 @@ module.exports = (socket) => { | ||
function send (message) { | ||
let bytelength = BUFFER.write(message, 4, "utf8") + 4; | ||
if (bytelength > BUFFER.length - 8) { | ||
bytelength = Buffer.byteLength(message, "utf8") + 4; | ||
BUFFER = Buffer.allocUnsafe(bytelength + 8); | ||
BUFFER.write(message, 4, "utf8"); | ||
} | ||
BUFFER.writeUInt32LE(bytelength, 0); | ||
this.write(BUFFER.slice(0, bytelength)); | ||
}; | ||
const body = Buffer.from(message, "utf8"); | ||
const head = Buffer.allocUnsafe(4); | ||
head.writeUInt32LE(body.length + 4, 0); | ||
this.write(head); | ||
this.write(body); | ||
} | ||
function ondata (buffer) { | ||
debugger; | ||
while (buffer.length) { | ||
@@ -26,0 +33,0 @@ // Not enough data to compute the message's bytelength |
{ | ||
"name": "antena", | ||
"description": "Isomorphic communication library for node and browsers", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Laurent Christophe", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32263
789