return new Uint8Array(value.match(/[0-9a-f]{2}/gi)?.map(b => parseInt(b, 16)) || [])
}
- if (!(value instanceof ArrayBuffer || value instanceof Uint8Array)) {
+ if (value instanceof ArrayBuffer) {
+ value = new Uint8Array(value)
+ }
+ if (!(value instanceof Uint8Array)) {
throw new TypeError(`${name} must be Uint8Array or ArrayBuffer`)
}
- const bytes = new Uint8Array(value.slice())
+ const bytes = value.slice()
if (bytes.byteLength < byteLengthMin) {
throw new TypeError(`${name} must be at least ${byteLengthMin} bytes`)
}