fix: 수정된 타입 정의 및 불필요한 캐스팅 제거
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
export type Bytes = ArrayBuffer | DataView | Uint8Array<ArrayBuffer>;
|
||||
export type Bytes = ArrayBuffer | DataView<ArrayBuffer> | Uint8Array<ArrayBuffer>;
|
||||
export type BytesLike = Bytes | string;
|
||||
|
||||
@@ -18,14 +18,13 @@ export function convertBytesLikeToUint8Array(
|
||||
return new Uint8Array(data);
|
||||
}
|
||||
if (data instanceof DataView) {
|
||||
const view = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
||||
return new Uint8Array(view) as Uint8Array<ArrayBuffer>;
|
||||
return new Uint8Array<ArrayBuffer>(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
if (typeof (data) === 'string') {
|
||||
if (encodeUTF8) {
|
||||
return (new TextEncoder()).encode(data) as Uint8Array<ArrayBuffer>;
|
||||
return (new TextEncoder()).encode(data);
|
||||
}
|
||||
return new Uint8Array(data.split('').map((s) => s.codePointAt(0) as number)) as Uint8Array<ArrayBuffer>;
|
||||
return new Uint8Array(data.split('').map((s) => s.codePointAt(0) as number));
|
||||
}
|
||||
throw new Error('Unsupported BytesLike');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user