(encoding, start, end)
| 479 | Buffer.byteLength = byteLength |
| 480 | |
| 481 | function slowToString (encoding, start, end) { |
| 482 | let loweredCase = false |
| 483 | |
| 484 | // No need to verify that "this.length <= MAX_UINT32" since it's a read-only |
| 485 | // property of a typed array. |
| 486 | |
| 487 | // This behaves neither like String nor Uint8Array in that we set start/end |
| 488 | // to their upper/lower bounds if the value passed is out of range. |
| 489 | // undefined is handled specially as per ECMA-262 6th Edition, |
| 490 | // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. |
| 491 | if (start === undefined || start < 0) { |
| 492 | start = 0 |
| 493 | } |
| 494 | // Return early if start > this.length. Done here to prevent potential uint32 |
| 495 | // coercion fail below. |
| 496 | if (start > this.length) { |
| 497 | return '' |
| 498 | } |
| 499 | |
| 500 | if (end === undefined || end > this.length) { |
| 501 | end = this.length |
| 502 | } |
| 503 | |
| 504 | if (end <= 0) { |
| 505 | return '' |
| 506 | } |
| 507 | |
| 508 | // Force coercion to uint32. This will also coerce falsey/NaN values to 0. |
| 509 | end >>>= 0 |
| 510 | start >>>= 0 |
| 511 | |
| 512 | if (end <= start) { |
| 513 | return '' |
| 514 | } |
| 515 | |
| 516 | if (!encoding) encoding = 'utf8' |
| 517 | |
| 518 | while (true) { |
| 519 | switch (encoding) { |
| 520 | case 'hex': |
| 521 | return hexSlice(this, start, end) |
| 522 | |
| 523 | case 'utf8': |
| 524 | case 'utf-8': |
| 525 | return utf8Slice(this, start, end) |
| 526 | |
| 527 | case 'ascii': |
| 528 | return asciiSlice(this, start, end) |
| 529 | |
| 530 | case 'latin1': |
| 531 | case 'binary': |
| 532 | return latin1Slice(this, start, end) |
| 533 | |
| 534 | case 'base64': |
| 535 | return base64Slice(this, start, end) |
| 536 | |
| 537 | case 'ucs2': |
| 538 | case 'ucs-2': |
nothing calls this directly
no test coverage detected
searching dependent graphs…