(encoding, start, end)
| 428 | } |
| 429 | Buffer.byteLength = byteLength; |
| 430 | function slowToString(encoding, start, end) { |
| 431 | var loweredCase = false; |
| 432 | |
| 433 | // No need to verify that "this.length <= MAX_UINT32" since it's a read-only |
| 434 | // property of a typed array. |
| 435 | |
| 436 | // This behaves neither like String nor Uint8Array in that we set start/end |
| 437 | // to their upper/lower bounds if the value passed is out of range. |
| 438 | // undefined is handled specially as per ECMA-262 6th Edition, |
| 439 | // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. |
| 440 | if (start === undefined || start < 0) { |
| 441 | start = 0; |
| 442 | } |
| 443 | // Return early if start > this.length. Done here to prevent potential uint32 |
| 444 | // coercion fail below. |
| 445 | if (start > this.length) { |
| 446 | return ''; |
| 447 | } |
| 448 | if (end === undefined || end > this.length) { |
| 449 | end = this.length; |
| 450 | } |
| 451 | if (end <= 0) { |
| 452 | return ''; |
| 453 | } |
| 454 | |
| 455 | // Force coercion to uint32. This will also coerce falsey/NaN values to 0. |
| 456 | end >>>= 0; |
| 457 | start >>>= 0; |
| 458 | if (end <= start) { |
| 459 | return ''; |
| 460 | } |
| 461 | if (!encoding) encoding = 'utf8'; |
| 462 | while (true) { |
| 463 | switch (encoding) { |
| 464 | case 'hex': |
| 465 | return hexSlice(this, start, end); |
| 466 | case 'utf8': |
| 467 | case 'utf-8': |
| 468 | return utf8Slice(this, start, end); |
| 469 | case 'ascii': |
| 470 | return asciiSlice(this, start, end); |
| 471 | case 'latin1': |
| 472 | case 'binary': |
| 473 | return latin1Slice(this, start, end); |
| 474 | case 'base64': |
| 475 | return base64Slice(this, start, end); |
| 476 | case 'ucs2': |
| 477 | case 'ucs-2': |
| 478 | case 'utf16le': |
| 479 | case 'utf-16le': |
| 480 | return utf16leSlice(this, start, end); |
| 481 | default: |
| 482 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); |
| 483 | encoding = (encoding + '').toLowerCase(); |
| 484 | loweredCase = true; |
| 485 | } |
| 486 | } |
| 487 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…