Skip to content

Commit 66bf708

Browse files
committed
Remove 0x prefix in hexToBytes.
1 parent 5175e98 commit 66bf708

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: src/utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// buf.toString('hex') -> toHex(buf)
22
import assert from "@noble/hashes/_assert";
3+
import { hexToBytes as _hexToBytes } from "@noble/hashes/utils";
34
const assertBool = assert.bool;
45
const assertBytes = assert.bytes;
56
export { assertBool, assertBytes };
67
export {
78
bytesToHex,
89
bytesToHex as toHex,
910
concatBytes,
10-
hexToBytes,
1111
createView,
1212
utf8ToBytes
1313
} from "@noble/hashes/utils";
@@ -20,6 +20,11 @@ export function bytesToUtf8(data: Uint8Array): string {
2020
return new TextDecoder().decode(data);
2121
}
2222

23+
export function hexToBytes(data: string): Uint8Array {
24+
const sliced = data.startsWith("0x") ? data.substring(2) : data;
25+
return _hexToBytes(sliced);
26+
}
27+
2328
// buf.equals(buf2) -> equalsBytes(buf, buf2)
2429
export function equalsBytes(a: Uint8Array, b: Uint8Array): boolean {
2530
if (a.length !== b.length) {

0 commit comments

Comments
 (0)