Add more encoder wrappers
This commit is contained in:
parent
dff22f2b41
commit
c9a0f009d9
40
bytes.ts
40
bytes.ts
@ -1,7 +1,15 @@
|
||||
import {
|
||||
decodeAscii85,
|
||||
decodeBase32,
|
||||
decodeBase58,
|
||||
decodeBase64,
|
||||
decodeBase64Url,
|
||||
decodeHex,
|
||||
encodeAscii85,
|
||||
encodeBase32,
|
||||
encodeBase58,
|
||||
encodeBase64,
|
||||
encodeBase64Url,
|
||||
encodeHex,
|
||||
} from "jsr:@std/encoding@^1.0.6";
|
||||
|
||||
@ -35,6 +43,22 @@ export function to_hex(b: BinaryLike): string {
|
||||
return encodeHex(to_utf8(b));
|
||||
}
|
||||
|
||||
export function from_base32(s: BinaryLike): Uint8Array {
|
||||
return decodeBase32(from_utf8(s));
|
||||
}
|
||||
|
||||
export function to_base32(b: BinaryLike): string {
|
||||
return encodeBase32(to_utf8(b));
|
||||
}
|
||||
|
||||
export function from_base58(s: BinaryLike): Uint8Array {
|
||||
return decodeBase58(from_utf8(s));
|
||||
}
|
||||
|
||||
export function to_base58(b: BinaryLike): string {
|
||||
return encodeBase58(to_utf8(b));
|
||||
}
|
||||
|
||||
export function from_base64(s: BinaryLike): Uint8Array {
|
||||
return decodeBase64(from_utf8(s));
|
||||
}
|
||||
@ -43,6 +67,22 @@ export function to_base64(b: BinaryLike): string {
|
||||
return encodeBase64(to_utf8(b));
|
||||
}
|
||||
|
||||
export function from_base64url(s: BinaryLike): Uint8Array {
|
||||
return decodeBase64Url(from_utf8(s));
|
||||
}
|
||||
|
||||
export function to_base64url(b: BinaryLike): string {
|
||||
return encodeBase64Url(to_utf8(b));
|
||||
}
|
||||
|
||||
export function from_ascii85(s: BinaryLike): Uint8Array {
|
||||
return decodeAscii85(from_utf8(s));
|
||||
}
|
||||
|
||||
export function to_ascii85(b: BinaryLike): string {
|
||||
return encodeAscii85(to_utf8(b));
|
||||
}
|
||||
|
||||
export function read_u8(b: Uint8Array, i = 0) {
|
||||
return b[i];
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@luaneko/lstd",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"exports": "./mod.ts"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user