feat: eslint 적용 및 관련 코드 일괄 수정
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import type { BytesLike } from './BytesLike.js';
|
||||
|
||||
export function convertBytesLikeToUint8Array(
|
||||
data: BytesLike,
|
||||
encodeUTF8 = true
|
||||
): Uint8Array<ArrayBuffer> {
|
||||
export function convertBytesLikeToUint8Array(data: BytesLike, encodeUTF8 = true): Uint8Array<ArrayBuffer> {
|
||||
if (data instanceof Uint8Array) {
|
||||
if (
|
||||
data.buffer instanceof ArrayBuffer
|
||||
&& data.byteOffset === 0
|
||||
&& data.byteLength === data.buffer.byteLength
|
||||
) {
|
||||
if (data.buffer instanceof ArrayBuffer && data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
||||
return data;
|
||||
}
|
||||
return new Uint8Array(data) as Uint8Array<ArrayBuffer>;
|
||||
@@ -20,9 +13,9 @@ export function convertBytesLikeToUint8Array(
|
||||
if (data instanceof DataView) {
|
||||
return new Uint8Array<ArrayBuffer>(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
if (typeof (data) === 'string') {
|
||||
if (typeof data === 'string') {
|
||||
if (encodeUTF8) {
|
||||
return (new TextEncoder()).encode(data);
|
||||
return new TextEncoder().encode(data);
|
||||
}
|
||||
return new Uint8Array(data.split('').map((s) => s.codePointAt(0) as number));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user