Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: change var to let/const #32037

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function WritableState(options, stream, isDuplex) {
}

WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
let current = this.bufferedRequest;
const out = [];
while (current) {
out.push(current);
Expand All @@ -201,7 +201,7 @@ WritableState.prototype.getBuffer = function getBuffer() {

// Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
let realHasInstance;
if (typeof Symbol === 'function' && SymbolHasInstance) {
realHasInstance = FunctionPrototype[SymbolHasInstance];
ObjectDefineProperty(Writable, SymbolHasInstance, {
Expand Down Expand Up @@ -351,7 +351,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
state.needDrain = true;

if (state.writing || state.corked || state.errored) {
var last = state.lastBufferedRequest;
const last = state.lastBufferedRequest;
state.lastBufferedRequest = {
chunk,
encoding,
Expand Down Expand Up @@ -424,7 +424,7 @@ function onwrite(stream, er) {
}
} else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state) || stream.destroyed;
const finished = needFinish(state) || stream.destroyed;

if (!finished &&
!state.corked &&
Expand Down Expand Up @@ -495,17 +495,17 @@ function errorBuffer(state, err) {
// If there's something in the buffer waiting, then process it
function clearBuffer(stream, state) {
state.bufferProcessing = true;
var entry = state.bufferedRequest;
let entry = state.bufferedRequest;

if (stream._writev && entry && entry.next) {
// Fast case, write everything using _writev()
var l = state.bufferedRequestCount;
var buffer = new Array(l);
var holder = state.corkedRequestsFree;
const l = state.bufferedRequestCount;
const buffer = new Array(l);
const holder = state.corkedRequestsFree;
holder.entry = entry;

var count = 0;
var allBuffers = true;
let count = 0;
let allBuffers = true;
while (entry) {
buffer[count] = entry;
if (entry.encoding !== 'buffer')
Expand All @@ -525,18 +525,18 @@ function clearBuffer(stream, state) {
state.corkedRequestsFree = holder.next;
holder.next = null;
} else {
var corkReq = { next: null, entry: null, finish: undefined };
const corkReq = { next: null, entry: null, finish: undefined };
corkReq.finish = onCorkedFinish.bind(undefined, corkReq, state);
state.corkedRequestsFree = corkReq;
}
state.bufferedRequestCount = 0;
} else {
// Slow case, write chunks one-by-one
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
const chunk = entry.chunk;
const encoding = entry.encoding;
const cb = entry.callback;
const len = state.objectMode ? 1 : chunk.length;

doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
Expand Down Expand Up @@ -692,10 +692,10 @@ function endWritable(stream, state, cb) {
}

function onCorkedFinish(corkReq, state, err) {
var entry = corkReq.entry;
let entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
const cb = entry.callback;
state.pendingcb--;
cb(err);
entry = entry.next;
Expand Down