(buf: Buffer)
| 580 | } |
| 581 | |
| 582 | function detectBinary(buf: Buffer): boolean { |
| 583 | if (buf.length === 0) return false; |
| 584 | let nonPrintable = 0; |
| 585 | for (let i = 0; i < buf.length; i++) { |
| 586 | const b = buf[i]!; |
| 587 | if (b === 0) return true; |
| 588 | |
| 589 | if (b === 9 || b === 10 || b === 13) continue; |
| 590 | if (b >= 32 && b <= 126) continue; |
| 591 | |
| 592 | nonPrintable++; |
| 593 | } |
| 594 | return nonPrintable / buf.length > FS_BINARY_NONPRINTABLE_FRACTION; |
| 595 | } |
| 596 | |
| 597 | async function readFileRange( |
| 598 | absPath: string, |
no outgoing calls
no test coverage detected