Skip to content

Commit

Permalink
Merge 8c9d713 into 807fe50
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpenev-s committed Mar 22, 2019
2 parents 807fe50 + 8c9d713 commit 4d20b6c
Show file tree
Hide file tree
Showing 62 changed files with 314 additions and 314 deletions.
4 changes: 2 additions & 2 deletions examples/app7.js
Expand Up @@ -68,13 +68,13 @@ function insert(statement, cb) {
1, 'SAP AG',
fs.createReadStream(path.join(dirname, 'sap.jpg')),
fs.createReadStream(path.join(dirname, 'logo.png')),
new Buffer('SAP headquarters located in Walldorf, Germany', 'ascii')
Buffer.from('SAP headquarters located in Walldorf, Germany', 'ascii')
],
[
2, 'SAP lobby',
fs.createReadStream(path.join(dirname, 'lobby.jpg')),
fs.createReadStream(path.join(dirname, 'locked.png')),
new Buffer('SAP lobby in Walldorf, Germany', 'ascii')
Buffer.from('SAP lobby in Walldorf, Germany', 'ascii')
]
];

Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/Connection.js
Expand Up @@ -275,7 +275,7 @@ Connection.prototype.send = function send(message, receive) {

var size = MAX_PACKET_SIZE - PACKET_HEADER_LENGTH;
var buffer = message.toBuffer(size);
var packet = new Buffer(PACKET_HEADER_LENGTH + buffer.length);
var packet = Buffer.allocUnsafe(PACKET_HEADER_LENGTH + buffer.length);
buffer.copy(packet, PACKET_HEADER_LENGTH);

var state = this._state;
Expand Down Expand Up @@ -618,6 +618,6 @@ InitializationReply.read = function readInitializationReply(buffer) {
return new InitializationReply(productVersion, protocolVersion);
};

var initializationRequestBuffer = new Buffer([
var initializationRequestBuffer = Buffer.from([
0xff, 0xff, 0xff, 0xff, 4, 20, 0, 4, 1, 0, 0, 1, 1, 1
]);
4 changes: 2 additions & 2 deletions lib/protocol/Reader.js
Expand Up @@ -97,7 +97,7 @@ Reader.prototype.readBytes = function readBytes(isString) {
this.buffer.slice(this.offset, this.offset + length),
this.scrictEncoding);
} else {
value = new Buffer(length);
value = Buffer.allocUnsafe(length);
this.buffer.copy(value, 0, this.offset, this.offset + length);
}
this.offset += length;
Expand Down Expand Up @@ -253,7 +253,7 @@ Reader.prototype.readLob = function readLob(type) {
chunk = this.buffer.slice(this.offset, this.offset + chunkLength);
this.offset += chunkLength;
} else {
chunk = new Buffer(0);
chunk = Buffer.allocUnsafe(0);
}
// if (!byteLength && !charLength) { return null; }
var ld = new LobDescriptor(type, options, charLength, byteLength, locatorId, chunk);
Expand Down
38 changes: 19 additions & 19 deletions lib/protocol/Writer.js
Expand Up @@ -281,7 +281,7 @@ Writer.prototype.finalizeWriteLobRequest = function finalizeWriteLobRequest(
// set reabable stream
stream = self._lobs[0];
// set lob header
header = new Buffer(WRITE_LOB_REQUEST_HEADER_LENGTH);
header = Buffer.allocUnsafe(WRITE_LOB_REQUEST_HEADER_LENGTH);
// set locatorId
stream._locatorId.copy(header, 0);
// update lob options in header
Expand Down Expand Up @@ -345,7 +345,7 @@ Writer.prototype.push = function push(buffer) {

Writer.prototype.pushNull = function pushNull(type) {
/* jshint bitwise:false */
var buffer = new Buffer([NormalizedTypeCode[type] | 0x80]);
var buffer = Buffer.from([NormalizedTypeCode[type] | 0x80]);
this.push(buffer);
};

Expand Down Expand Up @@ -373,7 +373,7 @@ Writer.prototype[TypeCode.TINYINT] = function writeTinyInt(value) {
if (isNaN(value)) {
throw createInputError('TINYINT');
}
var buffer = new Buffer(2);
var buffer = Buffer.allocUnsafe(2);
buffer[0] = TypeCode.TINYINT;
buffer.writeUInt8(value, 1);
this.push(buffer);
Expand All @@ -383,7 +383,7 @@ Writer.prototype[TypeCode.SMALLINT] = function writeSmallInt(value) {
if (isNaN(value)) {
throw createInputError('SMALLINT');
}
var buffer = new Buffer(3);
var buffer = Buffer.allocUnsafe(3);
buffer[0] = TypeCode.SMALLINT;
buffer.writeInt16LE(value, 1);
this.push(buffer);
Expand All @@ -393,7 +393,7 @@ Writer.prototype[TypeCode.INT] = function writeInt(value) {
if (isNaN(value)) {
throw createInputError('INT');
}
var buffer = new Buffer(5);
var buffer = Buffer.allocUnsafe(5);
buffer[0] = TypeCode.INT;
buffer.writeInt32LE(value, 1);
this.push(buffer);
Expand All @@ -403,7 +403,7 @@ Writer.prototype[TypeCode.BIGINT] = function writeBigInt(value) {
if (isNaN(value)) {
throw createInputError('BIGINT');
}
var buffer = new Buffer(9);
var buffer = Buffer.allocUnsafe(9);
buffer[0] = TypeCode.BIGINT;
bignum.writeInt64LE(buffer, value, 1);
this.push(buffer);
Expand All @@ -413,7 +413,7 @@ Writer.prototype[TypeCode.REAL] = function writeReal(value) {
if (isNaN(value)) {
throw createInputError('REAL');
}
var buffer = new Buffer(5);
var buffer = Buffer.allocUnsafe(5);
buffer[0] = TypeCode.REAL;
buffer.writeFloatLE(value, 1);
this.push(buffer);
Expand All @@ -423,7 +423,7 @@ Writer.prototype[TypeCode.DOUBLE] = function writeDouble(value) {
if (isNaN(value)) {
throw createInputError('DOUBLE');
}
var buffer = new Buffer(9);
var buffer = Buffer.allocUnsafe(9);
buffer[0] = TypeCode.DOUBLE;
buffer.writeDoubleLE(value, 1);
this.push(buffer);
Expand All @@ -438,7 +438,7 @@ Writer.prototype[TypeCode.DECIMAL] = function writeDecimal(value) {
} else {
throw createInputError('DECIMAL');
}
var buffer = new Buffer(17);
var buffer = Buffer.allocUnsafe(17);
buffer[0] = TypeCode.DECIMAL;
bignum.writeDec128(buffer, decimal, 1);
this.push(buffer);
Expand Down Expand Up @@ -469,24 +469,24 @@ Writer.prototype[TypeCode.BINARY] = function writeBinary(value) {
};

Writer.prototype[TypeCode.BLOB] = function writeBLob(value) {
var buffer = new Buffer(10);
var buffer = Buffer.allocUnsafe(10);
buffer.fill(0x00);
buffer[0] = TypeCode.BLOB;
this.pushLob(buffer, value);
};

Writer.prototype[TypeCode.CLOB] = function writeCLob(value) {
var buffer = new Buffer(10);
var buffer = Buffer.allocUnsafe(10);
buffer.fill(0x00);
buffer[0] = TypeCode.CLOB;
if (util.isString(value)) {
value = new Buffer(value, 'ascii');
value = Buffer.from(value, 'ascii');
}
this.pushLob(buffer, value);
};

Writer.prototype[TypeCode.NCLOB] = function writeNCLob(value) {
var buffer = new Buffer(10);
var buffer = Buffer.allocUnsafe(10);
buffer.fill(0x00);
buffer[0] = TypeCode.NCLOB;
if (util.isString(value)) {
Expand All @@ -509,7 +509,7 @@ Writer.prototype[TypeCode.TIME] = function writeTime(value) {
} else {
throw createInputError('TIME');
}
var buffer = new Buffer(5);
var buffer = Buffer.allocUnsafe(5);
buffer[0] = TypeCode.TIME;
buffer[1] = hours | 0x80;
buffer[2] = minutes;
Expand All @@ -531,7 +531,7 @@ Writer.prototype[TypeCode.DATE] = function writeDate(value) {
} else {
throw createInputError('DATE');
}
var buffer = new Buffer(5);
var buffer = Buffer.allocUnsafe(5);
buffer[0] = TypeCode.DATE;
buffer.writeUInt16LE(year, 1);
buffer[2] |= 0x80;
Expand All @@ -557,7 +557,7 @@ Writer.prototype[TypeCode.TIMESTAMP] = function writeTimestamp(value) {
} else {
throw createInputError('TIMESTAMP');
}
var buffer = new Buffer(9);
var buffer = Buffer.allocUnsafe(9);
buffer[0] = TypeCode.TIMESTAMP;
buffer.writeUInt16LE(year, 1);
buffer[2] |= 0x80;
Expand Down Expand Up @@ -622,18 +622,18 @@ function createBinaryOutBuffer(type, value) {
var length = value.length;
var buffer;
if (length <= 245) {
buffer = new Buffer(2 + length);
buffer = Buffer.allocUnsafe(2 + length);
buffer[0] = type;
buffer[1] = length;
value.copy(buffer, 2);
} else if (length <= 32767) {
buffer = new Buffer(4 + length);
buffer = Buffer.allocUnsafe(4 + length);
buffer[0] = type;
buffer[1] = 246;
buffer.writeInt16LE(length, 2);
value.copy(buffer, 4);
} else {
buffer = new Buffer(6 + length);
buffer = Buffer.allocUnsafe(6 + length);
buffer[0] = type;
buffer[1] = 247;
buffer.writeInt32LE(length, 2);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/auth/SAML.js
Expand Up @@ -31,7 +31,7 @@ SAML.prototype.initialize = function initialize(buffer) {
};

SAML.prototype.finalData = function finalData() {
return new Buffer(0);
return Buffer.allocUnsafe(0);
};

SAML.prototype.finalize = function finalize(buffer) {
Expand Down
10 changes: 5 additions & 5 deletions lib/protocol/auth/SCRAMSHA256.js
Expand Up @@ -30,7 +30,7 @@ function SCRAMSHA256(options) {
this.name = 'SCRAMSHA256';
this.password = options.password;
if (util.isString(this.password)) {
this.password = new Buffer(this.password, 'utf8');
this.password = Buffer.from(this.password, 'utf8');
}
this.clientChallenge = options.clientChallenge || createClientChallenge();
this.clientProof = undefined;
Expand Down Expand Up @@ -58,7 +58,7 @@ SCRAMSHA256.prototype.finalize = function finalize(buffer) {
};

function calculateClientProof(salts, serverKey, clientKey, password) {
var buf = new Buffer(2 + (CLIENT_PROOF_SIZE + 1) * salts.length);
var buf = Buffer.allocUnsafe(2 + (CLIENT_PROOF_SIZE + 1) * salts.length);
buf[0] = 0x00;
buf.writeInt8(salts.length, 1);
var offset = 2;
Expand All @@ -81,7 +81,7 @@ function scramble(salt, serverKey, clientKey, password) {

function xor(a, b) {
/* jshint bitwise:false */
var result = new Buffer(a.length);
var result = Buffer.allocUnsafe(a.length);
for (var i = 0; i < a.length; i++) {
result[i] = a[i] ^ b[i];
}
Expand All @@ -91,11 +91,11 @@ function xor(a, b) {
function hmac(key, msg) {
var hash = crypto.createHmac('sha256', key);
hash.update(msg);
return new Buffer(hash.digest(), 'binary');
return Buffer.from(hash.digest(), 'binary');
}

function sha256(msg) {
var hash = crypto.createHash('sha256');
hash.update(msg);
return new Buffer(hash.digest(), 'binary');
return Buffer.from(hash.digest(), 'binary');
}
6 changes: 3 additions & 3 deletions lib/protocol/auth/SessionCookie.js
Expand Up @@ -19,10 +19,10 @@ module.exports = SessionCookie;

function SessionCookie(options) {
this.name = 'SessionCookie';
var termId = new Buffer(util.cid, 'utf8');
var termId = Buffer.from(util.cid, 'utf8');
var rawSessionCookie = options.sessionCookie;
var length = rawSessionCookie.length + termId.length;
this.sessionCookie = new Buffer.concat([rawSessionCookie, termId], length);
this.sessionCookie = Buffer.concat([rawSessionCookie, termId], length);
}

SessionCookie.prototype.initialData = function initialData() {
Expand All @@ -34,7 +34,7 @@ SessionCookie.prototype.initialize = function initialize(buffer) {
};

SessionCookie.prototype.finalData = function finalData() {
return new Buffer(0);
return Buffer.allocUnsafe(0);
};

SessionCookie.prototype.finalize = function finalize(buffer) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/common/Constants.js
Expand Up @@ -25,7 +25,7 @@ module.exports = {
PART_HEADER_LENGTH: 16,
MAX_PACKET_SIZE: Math.pow(2, 17),
MAX_RESULT_SET_SIZE: Math.pow(2, 20),
EMPTY_BUFFER: new Buffer(0),
EMPTY_BUFFER: Buffer.allocUnsafe(0),
DEFAULT_CONNECT_OPTIONS: [{
name: ConnectOption.CLIENT_LOCALE,
value: 'en_US',
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/data/Fields.js
Expand Up @@ -49,7 +49,7 @@ function write(part, fields) {
fields = fields || this;

var byteLength = getByteLength(fields);
var buffer = new Buffer(byteLength);
var buffer = Buffer.allocUnsafe(byteLength);

buffer.writeUInt16LE(fields.length, 0);
offset += 2;
Expand All @@ -62,7 +62,7 @@ function write(part, fields) {
} else if (util.isArray(field)) {
data = write({}, field).buffer;
} else {
data = new Buffer(field, 'ascii');
data = Buffer.from(field, 'ascii');
}
fieldLength = data.length;
if (fieldLength <= 245) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/data/Int32.js
Expand Up @@ -39,7 +39,7 @@ function write(part, value) {
}
part = part || {};
part.argumentCount = getArgumentCount(value);
part.buffer = new Buffer(4);
part.buffer = Buffer.allocUnsafe(4);
part.buffer.writeInt32LE(value, 0);
return part;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/data/MultilineOptions.js
Expand Up @@ -45,7 +45,7 @@ function write(part, lines) {
lines = lines || this;
part = part || {};
var byteLength = getByteLength(lines);
var buffer = new Buffer(byteLength);
var buffer = Buffer.allocUnsafe(byteLength);
var options;
for (var i = 0; i < lines.length; i++) {
options = writeOptions({}, lines[i]);
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/data/Options.js
Expand Up @@ -87,7 +87,7 @@ function _read(buffer, offset) {
case TypeCode.BSTRING:
length = buffer.readInt16LE(offset);
offset += 2;
option.value = new Buffer(length);
option.value = Buffer.allocUnsafe(length);
buffer.copy(option.value, 0, offset, offset + length);
offset += length;
break;
Expand All @@ -105,7 +105,7 @@ function write(part, options) {
part = part || {};
options = options || this;
var byteLength = getByteLength(options);
var buffer = new Buffer(byteLength);
var buffer = Buffer.allocUnsafe(byteLength);
var option;
for (var i = 0; i < options.length; i++) {
option = options[i];
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/data/ReadLobRequest.js
Expand Up @@ -30,7 +30,7 @@ function write(part, req) {
part = part || {};
req = req || this;

var buffer = new Buffer(READ_LOB_REQUEST_LENGTH);
var buffer = Buffer.allocUnsafe(READ_LOB_REQUEST_LENGTH);
if (Buffer.isBuffer(req.locatorId)) {
req.locatorId.copy(buffer, offset, 0, 8);
} else {
Expand All @@ -49,7 +49,7 @@ function write(part, req) {

function read(part) {
var buffer = part.buffer;
var locatorId = new Buffer(8);
var locatorId = Buffer.allocUnsafe(8);
buffer.copy(locatorId, 0);
return {
locatorId: locatorId,
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/data/TextList.js
Expand Up @@ -26,7 +26,7 @@ function write(part, fields) {
fields = fields || this;

var byteLength = getByteLength(fields, part.useCesu8);
var buffer = new Buffer(byteLength);
var buffer = Buffer.allocUnsafe(byteLength);

var field, fieldLength, data;
for (var i = 0; i < fields.length; i++) {
Expand Down

0 comments on commit 4d20b6c

Please sign in to comment.