Package: effect
Module: Encoding
Decodes a base64 (RFC4648) string into bytes safely.
When to use
Use to decode a standard padded Base64 string into bytes without throwing on invalid input.
Details
Returns Result.succeed with a Uint8Array when decoding succeeds, or
Result.fail with an EncodingError when the input is not valid base64.
Example (Decoding Base64 bytes)
import { Encoding, Result } from "effect"
const result = Encoding.decodeBase64("SGVsbG8=")
if (Result.isSuccess(result)) {
console.log(Array.from(result.success)) // [72, 101, 108, 108, 111]
}
Signature
declare const decodeBase64: (str: string) => Result.Result<Uint8Array, EncodingError>
Since v2.0.0