variable / @typed/id/Ksuid

ksuid

Generates a KSUID from the current time and 16 random bytes.

Package version
1.0.0-beta.13
Category
ID generation
Since
1.0.0

Import

import { ksuid } from "@typed/id/Ksuid";

Signatures

export declare const ksuid: Effect.Effect<Ksuid, Cause.IllegalArgumentError, DateTimes | RandomValues>;

Why

Time and entropy remain explicit Effect services; timestamps outside KSUID’s 32-bit seconds field fail with IllegalArgumentError.

Ownership and lifetime

The Effect acquires no persistent resources and uses DateTimes and RandomValues only for the invocation.

Examples

import { ksuid } from "@typed/id/Ksuid"
import { DateTimes } from "@typed/id/DateTimes"
import { RandomValues } from "@typed/id/RandomValues"
import { Effect, Layer } from "effect"
const id = Effect.provide(ksuid, Layer.merge(DateTimes.Default, RandomValues.Default))

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source