Skip to content

Commit

Permalink
Use BufferEncoding in types (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcha authored Feb 10, 2024
1 parent 567f269 commit d3ceb0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bytebuf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ class ByteBuf extends DataView {
* @param byteEncoding The byte encoding.
* @returns The value.
*/
getString(byteOffset: number, byteLength?: number, byteEncoding?: string): string {
getString(byteOffset: number, byteLength?: number, byteEncoding?: BufferEncoding): string {

Check failure on line 842 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Cannot find name 'BufferEncoding'.

Check failure on line 842 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.

Check failure on line 842 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Cannot find name 'BufferEncoding'.

Check failure on line 842 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.
const decoder = new TextDecoder(byteEncoding || "utf-8")
const encoded = this.getUint8Array(byteOffset, byteLength)
return decoder.decode(encoded)
Expand All @@ -851,7 +851,7 @@ class ByteBuf extends DataView {
* @param byteEncoding The byte encoding.
* @returns The value.
*/
readString(byteLength?: number, byteEncoding?: string): string {
readString(byteLength?: number, byteEncoding?: BufferEncoding): string {

Check failure on line 854 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Cannot find name 'BufferEncoding'.

Check failure on line 854 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.

Check failure on line 854 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Cannot find name 'BufferEncoding'.

Check failure on line 854 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.
const value = this.getString(this.#byteOffset, byteLength, byteEncoding)
if (byteLength === undefined) {
this.#byteOffset = this.byteLength
Expand All @@ -868,7 +868,7 @@ class ByteBuf extends DataView {
* @param byteEncoding The byte encoding.
* @returns The byte length.
*/
setString(byteOffset: number, value: string, byteEncoding?: string): number {
setString(byteOffset: number, value: string, byteEncoding?: BufferEncoding): number {

Check failure on line 871 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Cannot find name 'BufferEncoding'.

Check failure on line 871 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.

Check failure on line 871 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Cannot find name 'BufferEncoding'.

Check failure on line 871 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.
// TODO: add support for "utf-16-be" and "utf-16-le"
if (byteEncoding && byteEncoding !== "utf-8") {
throw new TypeError("String encoding '" + byteEncoding + "' is not supported")
Expand All @@ -885,7 +885,7 @@ class ByteBuf extends DataView {
* @param value The string.
* @param byteEncoding The byte encoding.
*/
writeString(value: string, byteEncoding?: string): void {
writeString(value: string, byteEncoding?: BufferEncoding): void {

Check failure on line 888 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Cannot find name 'BufferEncoding'.

Check failure on line 888 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (12.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.

Check failure on line 888 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Cannot find name 'BufferEncoding'.

Check failure on line 888 in bytebuf.ts

View workflow job for this annotation

GitHub Actions / test (14.x)

Parameter 'byteEncoding' of public method from exported class has or is using private name 'BufferEncoding'.
const byteLength = this.setString(this.#byteOffset, value, byteEncoding)
this.#byteOffset += byteLength
}
Expand Down

0 comments on commit d3ceb0d

Please sign in to comment.