@layerzerolabs/common-encoding-utils 0.2.64 → 0.2.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +15 -7
- package/.turbo/turbo-lint.log +1 -1
- package/dist/2BTCXNB3.js +221 -0
- package/dist/2BTCXNB3.js.map +1 -0
- package/dist/DF2CBFKF.cjs +224 -0
- package/dist/DF2CBFKF.cjs.map +1 -0
- package/dist/byte-codec.cjs +12 -0
- package/dist/byte-codec.cjs.map +1 -0
- package/dist/byte-codec.d.ts +59 -0
- package/dist/byte-codec.d.ts.map +1 -0
- package/dist/byte-codec.js +3 -0
- package/dist/byte-codec.js.map +1 -0
- package/dist/index.cjs +32 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -8
- package/src/byte-codec.ts +265 -0
- package/src/index.ts +12 -2
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './byte-codec';
|
|
2
|
+
|
|
1
3
|
export type HexString = `0x${string}`;
|
|
2
4
|
|
|
3
5
|
const base58regex = /^[A-HJ-NP-Za-km-z1-9]*$/;
|
|
@@ -94,7 +96,9 @@ export function hexToBytes(hex: string): Uint8Array {
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
export function bytesToHex(bytes: Uint8Array | ArrayBuffer): string {
|
|
97
|
-
return Buffer.from(bytes).toString(
|
|
99
|
+
return Buffer.from(bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes).toString(
|
|
100
|
+
'hex',
|
|
101
|
+
);
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
/**
|
|
@@ -106,7 +110,13 @@ export function bytesToHexPrefixed(bytes: Uint8Array | ArrayBuffer): HexString {
|
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
export function bytesToBase64(bytes: Uint8Array | ArrayBuffer): string {
|
|
109
|
-
return Buffer.from(bytes).toString(
|
|
113
|
+
return Buffer.from(bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes).toString(
|
|
114
|
+
'base64',
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function base64ToBytes(base64: string): Uint8Array {
|
|
119
|
+
return Uint8Array.from(Buffer.from(base64, 'base64'));
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
export function hexToBase64(hexString: string): string {
|