Commit 596e5dbf authored by Julien Fontanet's avatar Julien Fontanet

chore: strict comparisons

parent 24adc6c7
......@@ -13,7 +13,7 @@ var SMB2Request = SMB2Forge.request;
*
*/
module.exports = function mkdir(path, mode, cb) {
if (typeof mode == 'function') {
if (typeof mode === 'function') {
cb = mode;
mode = '0777';
}
......
......@@ -19,7 +19,7 @@ var MAX_READ_LENGTH = require('../structures/constants').MAX_READ_LENGTH;
module.exports = function readFile(filename, options, cb) {
var connection = this;
if (typeof options == 'function') {
if (typeof options === 'function') {
cb = options;
options = {};
}
......@@ -55,7 +55,7 @@ module.exports = function readFile(filename, options, cb) {
var checkDone = function() {
if (stop) return;
createPackets();
if (nbRemainingPackets == 0 && offset.ge(fileLength)) {
if (nbRemainingPackets === 0 && offset.ge(fileLength)) {
SMB2Request('close', file, connection, function() {
if (options.encoding) {
result = result.toString(options.encoding);
......
......@@ -35,7 +35,7 @@ module.exports = function readdir(path, cb) {
return v.Filename;
}) // get the filename only
.filter(function(v) {
return v != '.' && v != '..';
return v !== '.' && v !== '..';
}) // remove '.' and '..' values
);
});
......
......@@ -16,7 +16,7 @@ var FILE_OPEN_IF = require('../structures/constants').FILE_OPEN_IF;
*
*/
module.exports = function rename(oldPath, newPath, options, cb) {
if (typeof options == 'function') {
if (typeof options === 'function') {
cb = options;
options = {};
}
......
......@@ -91,7 +91,7 @@ module.exports = function writeFile(filename, data, options, cb) {
function checkDone() {
if (stop) return;
createPackets();
if (nbRemainingPackets == 0 && offset.ge(fileLength)) {
if (nbRemainingPackets === 0 && offset.ge(fileLength)) {
fileWritten();
}
}
......
......@@ -29,7 +29,7 @@ function parseFiles(buffer) {
var files = [];
var offset = 0;
var nextFileOffset = -1;
while (nextFileOffset != 0) {
while (nextFileOffset !== 0) {
// extract next file offset
nextFileOffset = buffer.readUInt32LE(offset);
// extract the file
......
......@@ -9,7 +9,7 @@ var BigInt = (module.exports = function(n, v) {
v = v || 0;
if (v != 0) {
if (v !== 0) {
if (v < 0) {
this.sign = -1;
v = -v;
......@@ -23,7 +23,7 @@ var BigInt = (module.exports = function(n, v) {
for (var i = 0; i < size; i++) {
var start = (size - i - 1) * 2 - carry;
this.buffer.writeUInt8(
parseInt(start == -1 ? v.substr(0, 1) : v.substr(start, 2), 16),
parseInt(start === -1 ? v.substr(0, 1) : v.substr(start, 2), 16),
i
);
}
......@@ -58,7 +58,7 @@ BigInt.prototype.add = function(v) {
v = BigInt.toBigInt(this.buffer.length, v);
}
if (this.sign != v.sign) {
if (this.sign !== v.sign) {
return this.neg().sub(v);
}
......@@ -96,7 +96,7 @@ BigInt.prototype.sub = function(v) {
v = BigInt.toBigInt(this.buffer.length, v);
}
if (this.sign != v.sign) {
if (this.sign !== v.sign) {
return this.add(v.neg());
}
......@@ -167,7 +167,7 @@ BigInt.prototype.compare = function(v) {
for (var i = n - 1; i >= 0; i--) {
var a = i < this.buffer.length ? this.buffer.readUInt8(i) : 0;
var b = i < v.buffer.length ? v.buffer.readUInt8(i) : 0;
if (a != b) {
if (a !== b) {
return a > b ? this.sign : -this.sign;
}
}
......
......@@ -10,7 +10,7 @@ var defaults = {
return function(response) {
var h = response.getHeaders();
var err = MsErref.getStatus(bigint.fromBuffer(h.Status).toNumber());
if (err.code == self.successCode) {
if (err.code === self.successCode) {
self.onSuccess && self.onSuccess(connection, response);
cb && cb(null, self.parseResponse && self.parseResponse(response));
} else {
......
......@@ -132,7 +132,7 @@ function clearAutoCloseTimeout(connection) {
}
function setAutoCloseTimeout(connection) {
clearAutoCloseTimeout(connection);
if (connection.autoCloseTimeout != 0) {
if (connection.autoCloseTimeout !== 0) {
connection.scheduledAutoClose = setTimeout(function() {
SMB2Connection.close(connection);
}, connection.autoCloseTimeout);
......
......@@ -163,7 +163,7 @@ function dataToBuffer(data, length) {
}
// string to buffer
if (typeof data == 'string') {
if (typeof data === 'string') {
return Buffer.from(data);
}
......@@ -196,7 +196,7 @@ function readData(buffer, offset, length) {
function translate(key, value) {
if (
headerTranslates[key] &&
typeof headerTranslates[key][value] != 'undefined'
typeof headerTranslates[key][value] !== 'undefined'
) {
return headerTranslates[key][value];
}
......@@ -205,7 +205,7 @@ function translate(key, value) {
function unTranslate(key, value) {
if (headerTranslates[key]) {
for (var t in headerTranslates[key]) {
if (headerTranslates[key][t] == value) {
if (headerTranslates[key][t] === value) {
return t;
}
}
......@@ -262,7 +262,7 @@ function readResponse(message, buffer, offset) {
for (var i in message.structure.response) {
var key = message.structure.response[i][0];
var length = message.structure.response[i][1] || 1;
if (typeof length == 'string') {
if (typeof length === 'string') {
length = bufferToData(message.response[length]);
}
message.response[key] = readData(buffer, offset, length);
......@@ -279,9 +279,9 @@ function writeRequest(message, buffer, offset) {
var key = message.structure.request[i][0];
var length = message.structure.request[i][1] || 1;
var defaultValue = message.structure.request[i][2] || 0;
if (typeof length == 'string') {
if (typeof length === 'string') {
message.request[key] = message.request[key] || '';
if (message.request[length] != message.request[key].length) {
if (message.request[length] !== message.request[key].length) {
message.request[length] = message.request[key].length;
needsRewrite = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment