| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,7 @@ const constants = Object.defineProperties({}, { | |||
| 93 | 93 | }); | |
| 94 | 94 | ||
| 95 | 95 | Buffer.poolSize = 8 * 1024; | |
| 96 | - var poolSize, poolOffset, allocPool; | ||
| 96 | + let poolSize, poolOffset, allocPool; | ||
| 97 | 97 | ||
| 98 | 98 | setupBufferJS(Buffer.prototype, bindingObj); | |
| 99 | 99 | ||
@@ -212,7 +212,7 @@ Buffer.from = function from(value, encodingOrOffset, length) { | |||
| 212 | 212 | if (valueOf !== null && valueOf !== undefined && valueOf !== value) | |
| 213 | 213 | return Buffer.from(valueOf, encodingOrOffset, length); | |
| 214 | 214 | ||
| 215 | - var b = fromObject(value); | ||
| 215 | + const b = fromObject(value); | ||
| 216 | 216 | if (b) | |
| 217 | 217 | return b; | |
| 218 | 218 | ||
@@ -298,13 +298,10 @@ Buffer.allocUnsafeSlow = function allocUnsafeSlow(size) { | |||
| 298 | 298 | // If --zero-fill-buffers command line argument is set, a zero-filled | |
| 299 | 299 | // buffer is returned. | |
| 300 | 300 | function SlowBuffer(length) { | |
| 301 | - const len = +length; | ||
| 302 | - // eslint-disable-next-line eqeqeq | ||
| 303 | - if (len != length) | ||
| 304 | - length = 0; | ||
| 305 | - else | ||
| 306 | - assertSize(len); | ||
| 307 | - return createUnsafeBuffer(len); | ||
| 301 | + if (typeof length !== 'number') | ||
| 302 | + length = +length; | ||
| 303 | + assertSize(length); | ||
| 304 | + return createUnsafeBuffer(length); | ||
| 308 | 305 | } | |
| 309 | 306 | ||
| 310 | 307 | Object.setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype); | |
@@ -317,7 +314,7 @@ function allocate(size) { | |||
| 317 | 314 | if (size < (Buffer.poolSize >>> 1)) { | |
| 318 | 315 | if (size > (poolSize - poolOffset)) | |
| 319 | 316 | createPool(); | |
| 320 | - var b = new FastBuffer(allocPool, poolOffset, size); | ||
| 317 | + const b = new FastBuffer(allocPool, poolOffset, size); | ||
| 321 | 318 | poolOffset += size; | |
| 322 | 319 | alignPool(); | |
| 323 | 320 | return b; | |
@@ -326,7 +323,7 @@ function allocate(size) { | |||
| 326 | 323 | } | |
| 327 | 324 | ||
| 328 | 325 | function fromString(string, encoding) { | |
| 329 | - var length; | ||
| 326 | + let length; | ||
| 330 | 327 | if (typeof encoding !== 'string' || encoding.length === 0) { | |
| 331 | 328 | if (string.length === 0) | |
| 332 | 329 | return new FastBuffer(); | |
@@ -345,7 +342,7 @@ function fromString(string, encoding) { | |||
| 345 | 342 | ||
| 346 | 343 | if (length > (poolSize - poolOffset)) | |
| 347 | 344 | createPool(); | |
| 348 | - var b = new FastBuffer(allocPool, poolOffset, length); | ||
| 345 | + let b = new FastBuffer(allocPool, poolOffset, length); | ||
| 349 | 346 | const actual = b.write(string, encoding); | |
| 350 | 347 | if (actual !== length) { | |
| 351 | 348 | // byteLength() may overestimate. That's a rare case, though. | |
@@ -447,7 +444,7 @@ Buffer.isEncoding = function isEncoding(encoding) { | |||
| 447 | 444 | Buffer[kIsEncodingSymbol] = Buffer.isEncoding; | |
| 448 | 445 | ||
| 449 | 446 | Buffer.concat = function concat(list, length) { | |
| 450 | - var i; | ||
| 447 | + let i; | ||
| 451 | 448 | if (!Array.isArray(list)) { | |
| 452 | 449 | throw new ERR_INVALID_ARG_TYPE( | |
| 453 | 450 | 'list', ['Array', 'Buffer', 'Uint8Array'], list); | |
@@ -464,10 +461,10 @@ Buffer.concat = function concat(list, length) { | |||
| 464 | 461 | length = length >>> 0; | |
| 465 | 462 | } | |
| 466 | 463 | ||
| 467 | - var buffer = Buffer.allocUnsafe(length); | ||
| 468 | - var pos = 0; | ||
| 464 | + const buffer = Buffer.allocUnsafe(length); | ||
| 465 | + let pos = 0; | ||
| 469 | 466 | for (i = 0; i < list.length; i++) { | |
| 470 | - var buf = list[i]; | ||
| 467 | + const buf = list[i]; | ||
| 471 | 468 | if (!isUint8Array(buf)) { | |
| 472 | 469 | // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE. | |
| 473 | 470 | // Instead, find the proper error code for this. | |
@@ -772,7 +769,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 772 | 769 | } | |
| 773 | 770 | ||
| 774 | 771 | function slowIndexOf(buffer, val, byteOffset, encoding, dir) { | |
| 775 | - var loweredCase = false; | ||
| 772 | + let loweredCase = false; | ||
| 776 | 773 | for (;;) { | |
| 777 | 774 | switch (encoding) { | |
| 778 | 775 | case 'utf8': | |
@@ -907,7 +904,7 @@ Buffer.prototype.write = function write(string, offset, length, encoding) { | |||
| 907 | 904 | length = undefined; | |
| 908 | 905 | } | |
| 909 | 906 | ||
| 910 | - var remaining = this.length - offset; | ||
| 907 | + const remaining = this.length - offset; | ||
| 911 | 908 | if (length === undefined || length > remaining) | |
| 912 | 909 | length = remaining; | |
| 913 | 910 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments