mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
* feat(filters): add base64 encode and decode * fix: use Object.defineProperty for cross-platform btoa/atob mocking * docs(filters): update docs * docs(filters): update version
11 lines
273 B
TypeScript
11 lines
273 B
TypeScript
|
|
export function base64Encode (str: string): string {
|
|
return btoa(String.fromCharCode(...new TextEncoder().encode(str)))
|
|
}
|
|
|
|
export function base64Decode (str: string): string {
|
|
return new TextDecoder().decode(
|
|
Uint8Array.from(atob(str), c => c.charCodeAt(0))
|
|
)
|
|
}
|