16 lines
314 B
JavaScript
16 lines
314 B
JavaScript
export function filledDataView(bytes) {
|
|
const ab = new ArrayBuffer(bytes.length)
|
|
const dv = new DataView(ab)
|
|
|
|
for (let i = 0; i < bytes.length; i++) {
|
|
dv.setInt8(i, bytes[i])
|
|
}
|
|
|
|
return dv
|
|
}
|
|
|
|
export function sizedDataView(length) {
|
|
const ab = new ArrayBuffer(length)
|
|
return new DataView(ab)
|
|
}
|