Special property ‣ base64 - chung-leong/zigar GitHub Wiki

A base64 string containing the object's underlying bytes. Can be used to embed the content of a struct into a URL. Example:

pub const Hello = struct {
    number1: i32 = 0,
    number2: i32 = 0,
    number3: i32 = 0,
};
import { Hello } from './base64-example-1.zig';

const hello = new Hello({ number1: 1000, number2: 2000 });
const url = new URL(`http://example.net/?s=${hello.base64}`);
const helloCopy = new Hello({ base64: url.searchParams.get('s') });
console.log(hello.valueOf());
console.log(helloCopy.valueOf());
{ number1: 1000, number2: 2000, number3: 0 }
{ number1: 1000, number2: 2000, number3: 0 }

Special properites