* Buffer froms that should be allocs

* Remove unnecessary Buffer fill after alloc
*  minor cleanup on fnv1a.js
This commit is contained in:
David Stephens 2018-04-28 21:39:04 +01:00
parent 0d7676a871
commit b45a6a8743
3 changed files with 6 additions and 6 deletions

View File

@ -38,7 +38,7 @@ module.exports = class FNV1a {
digest(encoding) {
encoding = encoding || 'binary';
let buf = Buffer.alloc(4);
const buf = Buffer.alloc(4);
buf.writeInt32BE(this.hash & 0xffffffff, 0);
return buf.toString(encoding);
}

View File

@ -273,7 +273,7 @@ function Packet(options) {
};
this.getPacketHeaderBuffer = function(packetHeader) {
let buffer = Buffer.from(FTN_PACKET_HEADER_SIZE);
let buffer = Buffer.alloc(FTN_PACKET_HEADER_SIZE);
buffer.writeUInt16LE(packetHeader.origNode, 0);
buffer.writeUInt16LE(packetHeader.destNode, 2);
@ -311,7 +311,7 @@ function Packet(options) {
};
this.writePacketHeader = function(packetHeader, ws) {
let buffer = Buffer.from(FTN_PACKET_HEADER_SIZE);
let buffer = Buffer.alloc(FTN_PACKET_HEADER_SIZE);
buffer.writeUInt16LE(packetHeader.origNode, 0);
buffer.writeUInt16LE(packetHeader.destNode, 2);
@ -747,7 +747,7 @@ function Packet(options) {
async.waterfall(
[
function prepareHeaderAndKludges(callback) {
const basicHeader = Buffer.from(34);
const basicHeader = Buffer.alloc(34);
self.writeMessageHeader(message, basicHeader);
//
@ -864,7 +864,7 @@ function Packet(options) {
};
this.writeMessage = function(message, ws, options) {
let basicHeader = Buffer.from(34);
const basicHeader = Buffer.alloc(34);
self.writeMessageHeader(message, basicHeader);
ws.write(basicHeader);

View File

@ -46,7 +46,7 @@ exports.getQuotePrefix = getQuotePrefix;
// See list here: https://github.com/Mithgol/node-fidonet-jam
function stringToNullPaddedBuffer(s, bufLen) {
let buffer = Buffer.alloc(bufLen).fill(0x00);
let buffer = Buffer.alloc(bufLen);
let enc = iconv.encode(s, 'CP437').slice(0, bufLen);
for(let i = 0; i < enc.length; ++i) {
buffer[i] = enc[i];