Skip to content

Commit eeb5a08

Browse files
committed
Changed let to const where the variables were not mutated
1 parent 7b61642 commit eeb5a08

10 files changed

+39
-39
lines changed

dist/Counter.cjs.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function setupBitMapConstructors(blockSize) {
141141
* @param {function} callback
142142
*/
143143
allocate(callback) {
144-
let index = firstUnset(this.bitMap);
144+
const index = firstUnset(this.bitMap);
145145
if (index !== null) {
146146
setBit(this.bitMap, index);
147147
callback(this.begin + index, this.bitMap);
@@ -156,7 +156,7 @@ function setupBitMapConstructors(blockSize) {
156156
* @param {function} callback
157157
*/
158158
deallocate(counter, callback) {
159-
let index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
159+
const index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
160160
if (index >= 0 && index < blockSize) {
161161
unsetBit(this.bitMap, index);
162162
callback(this.bitMap);
@@ -188,7 +188,7 @@ function setupBitMapConstructors(blockSize) {
188188
* @param {Leaf|Node} child
189189
*/
190190
pushChild(child) {
191-
let index = this.bitMapTrees.push(child) - 1;
191+
const index = this.bitMapTrees.push(child) - 1;
192192
if (allSet(child.bitMap)) setBit(this.bitMap, index);
193193
}
194194

@@ -209,7 +209,7 @@ function setupBitMapConstructors(blockSize) {
209209
* @param {function} callback
210210
*/
211211
allocate(callback) {
212-
let index = firstUnset(this.bitMap);
212+
const index = firstUnset(this.bitMap);
213213
if (index === null) {
214214
callback(null, null);
215215
} else if (this.bitMapTrees[index]) {
@@ -224,7 +224,7 @@ function setupBitMapConstructors(blockSize) {
224224
if (this.bitMapTrees.length) {
225225
newBegin = this.bitMapTrees[index - 1].begin + Math.pow(blockSize, this.depth);
226226
}
227-
let newDepth = this.depth - 1;
227+
const newDepth = this.depth - 1;
228228
let child;
229229
if (newDepth === 0) {
230230
child = new Leaf(newBegin);
@@ -251,9 +251,9 @@ function setupBitMapConstructors(blockSize) {
251251
* @param {function} callback
252252
*/
253253
deallocate(counter, callback) {
254-
let index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
254+
const index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
255255
if (this.bitMapTrees[index]) {
256-
let allSetPrior = allSet(this.bitMapTrees[index].bitMap);
256+
const allSetPrior = allSet(this.bitMapTrees[index].bitMap);
257257
this.bitMapTrees[index].deallocate(counter, bitMap => {
258258
if (bitMap && allSetPrior) {
259259
unsetBit(this.bitMap, index);
@@ -314,7 +314,7 @@ class Counter {
314314
if (resultCounter !== null) {
315315
return this._begin + resultCounter;
316316
} else {
317-
let newRoot = new this._bitMapConst.Node(this._bitMapTree.begin, this._bitMapTree.depth + 1);
317+
const newRoot = new this._bitMapConst.Node(this._bitMapTree.begin, this._bitMapTree.depth + 1);
318318
newRoot.pushChild(this._bitMapTree);
319319
this._bitMapTree = newRoot;
320320
return this.allocate();

dist/Counter.es.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function setupBitMapConstructors(blockSize) {
137137
* @param {function} callback
138138
*/
139139
allocate(callback) {
140-
let index = firstUnset(this.bitMap);
140+
const index = firstUnset(this.bitMap);
141141
if (index !== null) {
142142
setBit(this.bitMap, index);
143143
callback(this.begin + index, this.bitMap);
@@ -152,7 +152,7 @@ function setupBitMapConstructors(blockSize) {
152152
* @param {function} callback
153153
*/
154154
deallocate(counter, callback) {
155-
let index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
155+
const index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
156156
if (index >= 0 && index < blockSize) {
157157
unsetBit(this.bitMap, index);
158158
callback(this.bitMap);
@@ -184,7 +184,7 @@ function setupBitMapConstructors(blockSize) {
184184
* @param {Leaf|Node} child
185185
*/
186186
pushChild(child) {
187-
let index = this.bitMapTrees.push(child) - 1;
187+
const index = this.bitMapTrees.push(child) - 1;
188188
if (allSet(child.bitMap)) setBit(this.bitMap, index);
189189
}
190190

@@ -205,7 +205,7 @@ function setupBitMapConstructors(blockSize) {
205205
* @param {function} callback
206206
*/
207207
allocate(callback) {
208-
let index = firstUnset(this.bitMap);
208+
const index = firstUnset(this.bitMap);
209209
if (index === null) {
210210
callback(null, null);
211211
} else if (this.bitMapTrees[index]) {
@@ -220,7 +220,7 @@ function setupBitMapConstructors(blockSize) {
220220
if (this.bitMapTrees.length) {
221221
newBegin = this.bitMapTrees[index - 1].begin + Math.pow(blockSize, this.depth);
222222
}
223-
let newDepth = this.depth - 1;
223+
const newDepth = this.depth - 1;
224224
let child;
225225
if (newDepth === 0) {
226226
child = new Leaf(newBegin);
@@ -247,9 +247,9 @@ function setupBitMapConstructors(blockSize) {
247247
* @param {function} callback
248248
*/
249249
deallocate(counter, callback) {
250-
let index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
250+
const index = Math.floor((counter - this.begin) / Math.pow(blockSize, this.depth));
251251
if (this.bitMapTrees[index]) {
252-
let allSetPrior = allSet(this.bitMapTrees[index].bitMap);
252+
const allSetPrior = allSet(this.bitMapTrees[index].bitMap);
253253
this.bitMapTrees[index].deallocate(counter, bitMap => {
254254
if (bitMap && allSetPrior) {
255255
unsetBit(this.bitMap, index);
@@ -310,7 +310,7 @@ class Counter {
310310
if (resultCounter !== null) {
311311
return this._begin + resultCounter;
312312
} else {
313-
let newRoot = new this._bitMapConst.Node(this._bitMapTree.begin, this._bitMapTree.depth + 1);
313+
const newRoot = new this._bitMapConst.Node(this._bitMapTree.begin, this._bitMapTree.depth + 1);
314314
newRoot.pushChild(this._bitMapTree);
315315
this._bitMapTree = newRoot;
316316
return this.allocate();

doc/Counter.js.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ <h1 class="page-title">Source: Counter.js</h1>
165165
* @param {function} callback
166166
*/
167167
allocate (callback) {
168-
let index = firstUnset(this.bitMap);
168+
const index = firstUnset(this.bitMap);
169169
if (index !== null) {
170170
setBit(this.bitMap, index);
171171
callback(this.begin + index, this.bitMap);
@@ -180,7 +180,7 @@ <h1 class="page-title">Source: Counter.js</h1>
180180
* @param {function} callback
181181
*/
182182
deallocate (counter, callback) {
183-
let index = Math.floor(
183+
const index = Math.floor(
184184
(counter - this.begin) / (blockSize ** this.depth)
185185
);
186186
if (index >= 0 &amp;&amp; index &lt; blockSize) {
@@ -214,7 +214,7 @@ <h1 class="page-title">Source: Counter.js</h1>
214214
* @param {Leaf|Node} child
215215
*/
216216
pushChild (child) {
217-
let index = this.bitMapTrees.push(child) - 1;
217+
const index = this.bitMapTrees.push(child) - 1;
218218
if (allSet(child.bitMap)) setBit(this.bitMap, index);
219219
}
220220

@@ -235,7 +235,7 @@ <h1 class="page-title">Source: Counter.js</h1>
235235
* @param {function} callback
236236
*/
237237
allocate (callback) {
238-
let index = firstUnset(this.bitMap);
238+
const index = firstUnset(this.bitMap);
239239
if (index === null) {
240240
callback(null, null);
241241
} else if (this.bitMapTrees[index]) {
@@ -252,7 +252,7 @@ <h1 class="page-title">Source: Counter.js</h1>
252252
this.bitMapTrees[index - 1].begin +
253253
(blockSize ** this.depth);
254254
}
255-
let newDepth = this.depth - 1;
255+
const newDepth = this.depth - 1;
256256
let child;
257257
if (newDepth === 0) {
258258
child = new Leaf(newBegin);
@@ -279,11 +279,11 @@ <h1 class="page-title">Source: Counter.js</h1>
279279
* @param {function} callback
280280
*/
281281
deallocate (counter, callback) {
282-
let index = Math.floor(
282+
const index = Math.floor(
283283
(counter - this.begin) / (blockSize ** this.depth)
284284
);
285285
if (this.bitMapTrees[index]) {
286-
let allSetPrior = allSet(this.bitMapTrees[index].bitMap);
286+
const allSetPrior = allSet(this.bitMapTrees[index].bitMap);
287287
this.bitMapTrees[index].deallocate(counter, (bitMap) => {
288288
if (bitMap &amp;&amp; allSetPrior) {
289289
unsetBit(this.bitMap, index);
@@ -345,7 +345,7 @@ <h1 class="page-title">Source: Counter.js</h1>
345345
if (resultCounter !== null) {
346346
return this._begin + resultCounter;
347347
} else {
348-
let newRoot = new this._bitMapConst.Node(
348+
const newRoot = new this._bitMapConst.Node(
349349
this._bitMapTree.begin,
350350
this._bitMapTree.depth + 1
351351
);
@@ -382,7 +382,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
382382
<br class="clear">
383383

384384
<footer>
385-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
385+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
386386
</footer>
387387

388388
<script> prettyPrint(); </script>

doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
5656
<br class="clear">
5757

5858
<footer>
59-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
59+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
6060
</footer>
6161

6262
<script> prettyPrint(); </script>

doc/module-Counter-BitMapTree.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
501501
<br class="clear">
502502

503503
<footer>
504-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
504+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
505505
</footer>
506506

507507
<script> prettyPrint(); </script>

doc/module-Counter-Counter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
489489
<br class="clear">
490490

491491
<footer>
492-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
492+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
493493
</footer>
494494

495495
<script> prettyPrint(); </script>

doc/module-Counter-Leaf.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
508508
<br class="clear">
509509

510510
<footer>
511-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
511+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
512512
</footer>
513513

514514
<script> prettyPrint(); </script>

doc/module-Counter-Node.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
753753
<br class="clear">
754754

755755
<footer>
756-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
756+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
757757
</footer>
758758

759759
<script> prettyPrint(); </script>

doc/module-Counter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Co
244244
<br class="clear">
245245

246246
<footer>
247-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Aug 29 2017 19:26:07 GMT+1000 (AEST)
247+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Oct 01 2017 15:25:33 GMT+1100 (AEDT)
248248
</footer>
249249

250250
<script> prettyPrint(); </script>

lib/Counter.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function setupBitMapConstructors (blockSize) {
137137
* @param {function} callback
138138
*/
139139
allocate (callback) {
140-
let index = firstUnset(this.bitMap);
140+
const index = firstUnset(this.bitMap);
141141
if (index !== null) {
142142
setBit(this.bitMap, index);
143143
callback(this.begin + index, this.bitMap);
@@ -152,7 +152,7 @@ function setupBitMapConstructors (blockSize) {
152152
* @param {function} callback
153153
*/
154154
deallocate (counter, callback) {
155-
let index = Math.floor(
155+
const index = Math.floor(
156156
(counter - this.begin) / (blockSize ** this.depth)
157157
);
158158
if (index >= 0 && index < blockSize) {
@@ -186,7 +186,7 @@ function setupBitMapConstructors (blockSize) {
186186
* @param {Leaf|Node} child
187187
*/
188188
pushChild (child) {
189-
let index = this.bitMapTrees.push(child) - 1;
189+
const index = this.bitMapTrees.push(child) - 1;
190190
if (allSet(child.bitMap)) setBit(this.bitMap, index);
191191
}
192192

@@ -207,7 +207,7 @@ function setupBitMapConstructors (blockSize) {
207207
* @param {function} callback
208208
*/
209209
allocate (callback) {
210-
let index = firstUnset(this.bitMap);
210+
const index = firstUnset(this.bitMap);
211211
if (index === null) {
212212
callback(null, null);
213213
} else if (this.bitMapTrees[index]) {
@@ -224,7 +224,7 @@ function setupBitMapConstructors (blockSize) {
224224
this.bitMapTrees[index - 1].begin +
225225
(blockSize ** this.depth);
226226
}
227-
let newDepth = this.depth - 1;
227+
const newDepth = this.depth - 1;
228228
let child;
229229
if (newDepth === 0) {
230230
child = new Leaf(newBegin);
@@ -251,11 +251,11 @@ function setupBitMapConstructors (blockSize) {
251251
* @param {function} callback
252252
*/
253253
deallocate (counter, callback) {
254-
let index = Math.floor(
254+
const index = Math.floor(
255255
(counter - this.begin) / (blockSize ** this.depth)
256256
);
257257
if (this.bitMapTrees[index]) {
258-
let allSetPrior = allSet(this.bitMapTrees[index].bitMap);
258+
const allSetPrior = allSet(this.bitMapTrees[index].bitMap);
259259
this.bitMapTrees[index].deallocate(counter, (bitMap) => {
260260
if (bitMap && allSetPrior) {
261261
unsetBit(this.bitMap, index);
@@ -317,7 +317,7 @@ class Counter {
317317
if (resultCounter !== null) {
318318
return this._begin + resultCounter;
319319
} else {
320-
let newRoot = new this._bitMapConst.Node(
320+
const newRoot = new this._bitMapConst.Node(
321321
this._bitMapTree.begin,
322322
this._bitMapTree.depth + 1
323323
);

0 commit comments

Comments
 (0)