Rename and export asLatin1

This commit is contained in:
Tony Garnock-Jones 2021-03-17 12:56:49 +01:00
parent e6f99ae2e1
commit 05c7343983
1 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ export interface EncoderPointerOptions<T> extends EncoderOptions {
encodePointer?: (e: Encoder<T>, v: T) => void;
}
function chunkStr(bs: Uint8Array): string {
export function asLatin1(bs: Uint8Array): string {
return String.fromCharCode.apply(null, bs as any as number[]);
}
@ -87,12 +87,12 @@ export class Encoder<T> {
/* Like contents(), but hands back a string containing binary data "encoded" via latin-1 */
contentsString(): string {
if (this.chunks.length === 0) {
const s = chunkStr(new Uint8Array(this.view.buffer, 0, this.index));
const s = asLatin1(new Uint8Array(this.view.buffer, 0, this.index));
this.index = 0;
return s;
} else {
this.rotatebuffer(4096);
return this.chunks.map(chunkStr).join('');
return this.chunks.map(asLatin1).join('');
}
}