Skip to content
Permalink
Browse files

lib: replace var with let/const

PR-URL: #30394
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
kresimir-franin authored and BridgeAR committed Nov 12, 2019
1 parent 16f60ce commit 97ce0a3b478481d66747b9137e942f2c73e7ba5f
Showing with 30 additions and 30 deletions.
  1. +30 −30 lib/zlib.js
@@ -92,8 +92,8 @@ const codes = {
};

const ckeys = ObjectKeys(codes);
for (var ck = 0; ck < ckeys.length; ck++) {
var ckey = ckeys[ck];
for (let ck = 0; ck < ckeys.length; ck++) {
const ckey = ckeys[ck];
codes[codes[ckey]] = ckey;
}

@@ -131,14 +131,14 @@ function zlibBufferOnError(err) {
}

function zlibBufferOnEnd() {
var buf;
var err;
let buf;
let err;
if (this.nread >= kMaxLength) {
err = new ERR_BUFFER_TOO_LARGE();
} else if (this.nread === 0) {
buf = Buffer.alloc(0);
} else {
var bufs = this.buffers;
const bufs = this.buffers;
buf = (bufs.length === 1 ? bufs[0] : Buffer.concat(bufs, this.nread));
}
this.close();
@@ -230,7 +230,7 @@ const checkRangesOrGetDefault = hideStackFrames(

// The base class for all Zlib-style streams.
function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
var chunkSize = Z_DEFAULT_CHUNK;
let chunkSize = Z_DEFAULT_CHUNK;
// The ZlibBase class is not exported to user land, the mode should only be
// passed in by us.
assert(typeof mode === 'number');
@@ -379,7 +379,7 @@ ZlibBase.prototype._destroy = function(err, callback) {
};

ZlibBase.prototype._transform = function(chunk, encoding, cb) {
var flushFlag = this._defaultFlushFlag;
let flushFlag = this._defaultFlushFlag;
// We use a 'fake' zero-length chunk to carry information about flushes from
// the public API to the actual stream implementation.
if (typeof chunk[kFlushFlag] === 'number') {
@@ -403,22 +403,22 @@ ZlibBase.prototype._processChunk = function(chunk, flushFlag, cb) {
};

function processChunkSync(self, chunk, flushFlag) {
var availInBefore = chunk.byteLength;
var availOutBefore = self._chunkSize - self._outOffset;
var inOff = 0;
var availOutAfter;
var availInAfter;

var buffers = null;
var nread = 0;
var inputRead = 0;
let availInBefore = chunk.byteLength;
let availOutBefore = self._chunkSize - self._outOffset;
let inOff = 0;
let availOutAfter;
let availInAfter;

let buffers = null;
let nread = 0;
let inputRead = 0;
const state = self._writeState;
const handle = self._handle;
var buffer = self._outBuffer;
var offset = self._outOffset;
let buffer = self._outBuffer;
let offset = self._outOffset;
const chunkSize = self._chunkSize;

var error;
let error;
self.on('error', function onError(er) {
error = er;
});
@@ -437,12 +437,12 @@ function processChunkSync(self, chunk, flushFlag) {
availOutAfter = state[0];
availInAfter = state[1];

var inDelta = (availInBefore - availInAfter);
const inDelta = (availInBefore - availInAfter);
inputRead += inDelta;

var have = availOutBefore - availOutAfter;
const have = availOutBefore - availOutAfter;
if (have > 0) {
var out = buffer.slice(offset, offset + have);
const out = buffer.slice(offset, offset + have);
offset += have;
if (!buffers)
buffers = [out];
@@ -527,7 +527,7 @@ function processCallback() {

const have = handle.availOutBefore - availOutAfter;
if (have > 0) {
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
const out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
self._outOffset += have;
self.push(out);
} else {
@@ -599,11 +599,11 @@ const zlibDefaultOpts = {
// Base class for all streams actually backed by zlib and using zlib-specific
// parameters.
function Zlib(opts, mode) {
var windowBits = Z_DEFAULT_WINDOWBITS;
var level = Z_DEFAULT_COMPRESSION;
var memLevel = Z_DEFAULT_MEMLEVEL;
var strategy = Z_DEFAULT_STRATEGY;
var dictionary;
let windowBits = Z_DEFAULT_WINDOWBITS;
let level = Z_DEFAULT_COMPRESSION;
let memLevel = Z_DEFAULT_MEMLEVEL;
let strategy = Z_DEFAULT_STRATEGY;
let dictionary;

if (opts) {
// windowBits is special. On the compression side, 0 is an invalid value.
@@ -912,8 +912,8 @@ ObjectDefineProperties(module.exports, {
// These should be considered deprecated
// expose all the zlib constants
const bkeys = ObjectKeys(constants);
for (var bk = 0; bk < bkeys.length; bk++) {
var bkey = bkeys[bk];
for (let bk = 0; bk < bkeys.length; bk++) {
const bkey = bkeys[bk];
if (bkey.startsWith('BROTLI')) continue;
ObjectDefineProperty(module.exports, bkey, {
enumerable: false, value: constants[bkey], writable: false

0 comments on commit 97ce0a3

Please sign in to comment.
You can’t perform that action at this time.