MCPcopy Create free account
hub / github.com/LibPDF-js/core / toAsciiString

Function toAsciiString

src/test-utils.ts:104–112  ·  view source on GitHub ↗
(bytes: Uint8Array, maxLength = 200)

Source from the content-addressed store, hash-verified

102 * @returns ASCII string representation
103 */
104export function toAsciiString(bytes: Uint8Array, maxLength = 200) {
105 const slice = bytes.slice(0, maxLength);
106
107 const ascii = Array.from(slice)
108 .map(b => (b >= 0x20 && b < 0x7f ? String.fromCharCode(b) : "."))
109 .join("");
110
111 return bytes.length > maxLength ? `${ascii}...` : ascii;
112}
113
114/**
115 * Assert that two Uint8Arrays are equal.

Callers 2

index.test.tsFile · 0.90
acro-form.test.tsFile · 0.90

Calls 3

sliceMethod · 0.80
mapMethod · 0.80
fromMethod · 0.80

Tested by

no test coverage detected