handle non-arrays
This commit is contained in:
@@ -24,6 +24,7 @@ export function bytesToText(bytes) {
|
|||||||
return new TextDecoder().decode(bytes);
|
return new TextDecoder().decode(bytes);
|
||||||
}
|
}
|
||||||
export function bytesToBits(bytes) {
|
export function bytesToBits(bytes) {
|
||||||
|
if(!Array.isArray(bytes)) return [];
|
||||||
return bytes.reduce((bits, byte) => [
|
return bytes.reduce((bits, byte) => [
|
||||||
...bits,
|
...bits,
|
||||||
...byte.toString(2).padStart(8, '0').split('').map(Number)
|
...byte.toString(2).padStart(8, '0').split('').map(Number)
|
||||||
|
|||||||
Reference in New Issue
Block a user