workspace/ids#

Classes#

MissingIdError#

Defined in: workspace/ids.ts:154

Thrown by an IdSource asked for more IDs than its command carries when it has no minter; the reducer refuses the command for it.

Extends#

  • Error

Constructors#

Constructor#

new MissingIdError(given): MissingIdError

Defined in: workspace/ids.ts:156

Parameters#
given#

number

Returns#

MissingIdError

Overrides#

Error.constructor

Properties#

given#

readonly given: number

Defined in: workspace/ids.ts:155

Interfaces#

IdMinter#

Defined in: workspace/ids.ts:91

A minter: its seed (modulo 2^64), its length, and the next ID it mints for a prefix.

Properties#

length#

readonly length: number

Defined in: workspace/ids.ts:93

seed#

readonly seed: bigint

Defined in: workspace/ids.ts:92

Methods#

copy()#

copy(): IdMinter

Defined in: workspace/ids.ts:100

A minter of this one’s seed and length at its count: it mints what this one mints next, and minting from either leaves the other where it was.

Returns#

IdMinter

mint()#

mint(prefix): string

Defined in: workspace/ids.ts:95

The next ID: prefix, _ and the next suffix of the minter.

Parameters#
prefix#

string

Returns#

string


IdMinterOptions#

Defined in: workspace/ids.ts:104

The options of createIdMinter.

Properties#

length?#

readonly optional length?: number

Defined in: workspace/ids.ts:108

The number of base-36 characters of a suffix, 1 to 13; 13 by default.

seed?#

readonly optional seed?: bigint

Defined in: workspace/ids.ts:106

The seed, taken modulo 2^64; 64 random bits when left out.


IdSource#

Defined in: workspace/ids.ts:168

Where the reducer takes the IDs of what a command creates, in the order it creates them: the IDs the command carries first, then, with a minter, those the minter mints.

Properties#

left#

readonly left: number

Defined in: workspace/ids.ts:174

How many given IDs no call took.

take#

readonly take: Mint

Defined in: workspace/ids.ts:170

The next ID; throws MissingIdError past the given IDs without a minter.

taken#

readonly taken: readonly string[]

Defined in: workspace/ids.ts:172

Every ID taken so far, in order.

Type Aliases#

Mint#

Mint = (prefix) => string

Defined in: workspace/ids.ts:148

What gives an ID to an element a command creates: one for each call, for an element of prefix.

Parameters#

prefix#

string

Returns#

string

Variables#

ANCHOR_PREFIX#

const ANCHOR_PREFIX: "anchor" = "anchor"

Defined in: workspace/ids.ts:60

The prefix of an alignment anchor’s ID.


CONVERSION_MAP_PREFIX#

const CONVERSION_MAP_PREFIX: "cmap" = "cmap"

Defined in: workspace/ids.ts:72

The prefix of a conversion map’s ID.


ELISION_PREFIX#

const ELISION_PREFIX: "elision" = "elision"

Defined in: workspace/ids.ts:54

The prefix of an elision’s ID.


FLOW_MAP_PREFIX#

const FLOW_MAP_PREFIX: "flow" = "flow"

Defined in: workspace/ids.ts:66

The prefix of a FlowMap’s ID.


GROUP_PREFIX#

const GROUP_PREFIX: "group" = "group"

Defined in: workspace/ids.ts:63

The prefix of a group’s ID.


ID_LENGTH#

const ID_LENGTH: 13 = 13

Defined in: workspace/ids.ts:75

The number of base-36 characters of a minted ID’s suffix by default.


MATCHSTAMP_PREFIX#

const MATCHSTAMP_PREFIX: "matchstamp" = "matchstamp"

Defined in: workspace/ids.ts:57

The prefix of a named MatchStamp’s ID.


REGION_PREFIX#

const REGION_PREFIX: "region" = "region"

Defined in: workspace/ids.ts:69

The prefix of a region’s ID.


TIMELINE_PREFIX#

const TIMELINE_PREFIX: object

Defined in: workspace/ids.ts:41

The prefix of a minted timeline ID (clt_…, dpt_…, …) by its timeline class.

Type Declaration#

ContinuousGraphicalTimeline#

readonly ContinuousGraphicalTimeline: "cgt" = "cgt"

ContinuousLogicalTimeline#

readonly ContinuousLogicalTimeline: "clt" = "clt"

ContinuousPhysicalTimeline#

readonly ContinuousPhysicalTimeline: "cpt" = "cpt"

DiscreteGraphicalTimeline#

readonly DiscreteGraphicalTimeline: "dgt" = "dgt"

DiscreteLogicalTimeline#

readonly DiscreteLogicalTimeline: "dlt" = "dlt"

DiscretePhysicalTimeline#

readonly DiscretePhysicalTimeline: "dpt" = "dpt"


TIMESTAMP_PREFIX#

const TIMESTAMP_PREFIX: "timestamp" = "timestamp"

Defined in: workspace/ids.ts:51

The prefix of a named timestamp’s ID.

Functions#

createIdMinter()#

createIdMinter(options?): IdMinter

Defined in: workspace/ids.ts:122

A minter of seed (64 random bits when left out) and length (13 by default); a length that is not an integer from 1 to 13 throws a RangeError.

Parameters#

options?#

IdMinterOptions = {}

Returns#

IdMinter


idSource()#

idSource(given, minter?): IdSource

Defined in: workspace/ids.ts:178

A source taking given in order, then minting with minter, where there is one.

Parameters#

given#

readonly string[]

minter?#

IdMinter | null = null

Returns#

IdSource


mintBlockId()#

mintBlockId(fill?): string

Defined in: workspace/ids.ts:27

A fresh block id: ten random base-36 characters, so concurrent peers never collide.

Parameters#

fill?#

(bytes) => void

Returns#

string


mix64()#

mix64(x): bigint

Defined in: workspace/ids.ts:80

SplitMix64’s finalizer over 64-bit integers, a bijection: x is taken modulo 2^64.

Parameters#

x#

bigint

Returns#

bigint