pinVersion
ref / conversations / pinVersion
Takes a version number and state management functions that are pinned to this version.
The two functions it returns are versionify
and unpack
. The former can be used to add a version to some data. The latter can be used to unpack the data again, validating the version on the fly.
ts
import { assert } from "jsr:@std/assert";
const { versionify, unpack } = pinVersion(42);
const data = { prop: "pizza" };
const versioned = versionify(data);
const unpacked = unpack(versioned);
assert(data === unpacked);
Parameters
version
ts
version: string | number
the version to use for pinning