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

chore: strict comparisons

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