lib0

Search for an npm package

lib0

module "lib0" {
export * as array from {
export function last<L>(arr: ArrayLike<L>): L
export function create<C>(): C[]
export function copy<D>(a: D[]): D[]
export function appendTo<M>(dest: M[], src: M[]): void
export function every<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : any): boolean
export function some<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : never): boolean
export function equalFlat<ELEM>(a: ArrayLike<ELEM>, b: ArrayLike<ELEM>): boolean
export function flatten<ELEM>(arr: ELEM[][]): ELEM[]
export function unfold<T_1>(len: number, f: (arg0: number, arg1: T_1[]) => T_1): T_1[]
export function fold<T_1, RESULT>(arr: T_1[], seed: RESULT, folder: (arg0: RESULT, arg1: T_1, arg2: number) => RESULT): RESULT
export function unique<T_1>(arr: T_1[]): T_1[]
export function uniqueBy<T_1, M>(arr: ArrayLike<T_1>, mapper: (arg0: T_1) => M): T_1[]
export function map<ARR extends ArrayLike<any>, MAPPER extends (arg0: ARR extends ArrayLike<infer T_1> ? T_1 : never, arg1: number, arg2: ARR) => any>(arr: ARR, mapper: MAPPER): MAPPER extends (...args: any[]) => infer M ? M : never[]
export function bubblesortItem<T_1>(arr: T_1[], i: number, compareFn: (a: T_1, b: T_1) => number): number

Transforms something array-like to an actual Array.

more
less

@function —

@template —

@param —

@return —

export const from: {
<T_1>(arrayLike: ArrayLike<T_1>): T_1[];
<T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
<T_1>(iterable: Iterable<T_1> | ArrayLike<T_1>): T_1[];
<T_1, U>(iterable: Iterable<T_1> | ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
} = ...
export const isArray: (arg: any) => arg is any[] = ...
}

Binary data constants.

export * as binary from {

n-th bit activated.

more
less

@type —

export const BIT1: number = ...
export const BIT2: 2 = ...
export const BIT3: 4 = ...
export const BIT4: 8 = ...
export const BIT5: 16 = ...
export const BIT6: 32 = ...
export const BIT7: 64 = ...
export const BIT8: 128 = ...
export const BIT9: 256 = ...
export const BIT10: 512 = ...
export const BIT11: 1024 = ...
export const BIT12: 2048 = ...
export const BIT13: 4096 = ...
export const BIT14: 8192 = ...
export const BIT15: 16384 = ...
export const BIT16: 32768 = ...
export const BIT17: 65536 = ...
export const BIT18: number = ...
export const BIT19: number = ...
export const BIT20: number = ...
export const BIT21: number = ...
export const BIT22: number = ...
export const BIT23: number = ...
export const BIT24: number = ...
export const BIT25: number = ...
export const BIT26: number = ...
export const BIT27: number = ...
export const BIT28: number = ...
export const BIT29: number = ...
export const BIT30: number = ...
export const BIT31: number = ...
export const BIT32: number = ...

First n bits activated.

more
less

@type —

export const BITS0: number = ...
export const BITS1: 1 = ...
export const BITS2: 3 = ...
export const BITS3: 7 = ...
export const BITS4: 15 = ...
export const BITS5: 31 = ...
export const BITS6: 63 = ...
export const BITS7: 127 = ...
export const BITS8: 255 = ...
export const BITS9: 511 = ...
export const BITS10: 1023 = ...
export const BITS11: 2047 = ...
export const BITS12: 4095 = ...
export const BITS13: 8191 = ...
export const BITS14: 16383 = ...
export const BITS15: 32767 = ...
export const BITS16: 65535 = ...
export const BITS17: number = ...
export const BITS18: number = ...
export const BITS19: number = ...
export const BITS20: number = ...
export const BITS21: number = ...
export const BITS22: number = ...
export const BITS23: number = ...
export const BITS24: number = ...
export const BITS25: number = ...
export const BITS26: number = ...
export const BITS27: number = ...
export const BITS28: number = ...
export const BITS29: number = ...
export const BITS30: number = ...

@type —

export const BITS31: number = ...

@type —

export const BITS32: number = ...
}
export * as broadcastchannel from {
export function subscribe(room: string, f: (arg0: any, arg1: any) => any): (arg0: any, arg1: any) => any
export function unsubscribe(room: string, f: (arg0: any, arg1: any) => any): boolean
export function publish(room: string, data: any, origin?: any): void
export type Channel = {
subs: Set<(arg0: any, arg1: any) => any>;
bc: any;
}
}
export * as buffer from {
export function createUint8ArrayFromLen(len: number): Uint8Array<ArrayBuffer>
export function createUint8ArrayViewFromArrayBuffer(buffer: ArrayBuffer, byteOffset: number, length: number): Uint8Array<ArrayBuffer>
export function createUint8ArrayFromArrayBuffer(buffer: ArrayBuffer): Uint8Array<ArrayBuffer>

@param —

more
less

@return —

export function toBase64(bytes: Uint8Array): string

@param —

more
less

@return —

export function fromBase64(s: string): Uint8Array<ArrayBuffer>
export function toBase64UrlEncoded(buf: Uint8Array): string
export function fromBase64UrlEncoded(base64: string): Uint8Array<ArrayBuffer>
export function toHexString(buf: Uint8Array): string
export function fromHexString(hex: string): Uint8Array<ArrayBuffer>
export function copyUint8Array(uint8Array: Uint8Array): Uint8Array
export function encodeAny(data: any): Uint8Array
export function decodeAny(buf: Uint8Array): any
export function shiftNBitsLeft(bs: Uint8Array, N: number): Uint8Array<ArrayBufferLike>
}
export * as conditions from {
export function undefinedToNull<T>(v: T | null | undefined): T | null
}
export * as decoding from {
export function createDecoder<Buf extends ArrayBufferLike>(uint8Array: Uint8Array<Buf>): Decoder<Buf>
export function hasContent(decoder: Decoder): boolean
export function clone(decoder: Decoder, newPos?: number): Decoder
export function readUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>, len: number): Uint8Array<Buf>
export function readVarUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>): Uint8Array<Buf>
export function readTailAsUint8Array(decoder: Decoder): Uint8Array
export function skip8(decoder: Decoder): number
export function readUint8(decoder: Decoder): number
export function readUint16(decoder: Decoder): number
export function readUint32(decoder: Decoder): number
export function readUint32BigEndian(decoder: Decoder): number
export function peekUint8(decoder: Decoder): number
export function peekUint16(decoder: Decoder): number
export function peekUint32(decoder: Decoder): number
export function readVarUint(decoder: Decoder): number
export function readVarInt(decoder: Decoder): number
export function peekVarUint(decoder: Decoder): number
export function peekVarInt(decoder: Decoder): number
export function _readVarStringPolyfill(decoder: Decoder): string
export function _readVarStringNative(decoder: Decoder): string
export function readVarString(decoder: Decoder): string
export function readTerminatedUint8Array(decoder: Decoder): Uint8Array
export function readTerminatedString(decoder: Decoder): string
export function peekVarString(decoder: Decoder): string
export function readFromDataView(decoder: Decoder, len: number): DataView
export function readFloat32(decoder: Decoder): number
export function readFloat64(decoder: Decoder): number
export function readBigInt64(decoder: Decoder): any
export function readBigUint64(decoder: Decoder): any
export function readAny(decoder: Decoder): any

A Decoder handles the decoding of an Uint8Array.

more
less

@template —

export class Decoder<Buf extends ArrayBufferLike = ArrayBufferLike> {

@param — Binary data to decode

constructor(uint8Array: Uint8Array<Buf>)

Decoding target.

more
less

@type —

arr: Uint8Array<Buf>;

Current decoding position.

more
less

@type —

pos: number;
}
Referenced by

T must not be null.

more
less

@template —

export class RleDecoder<T> extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, reader: (arg0: Decoder) => T)

The reader

reader: (arg0: Decoder) => T;

Current state

more
less

@type —

s: T | null;
count: number;
read(): T;
}
export class IntDiffDecoder extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, start: number)

Current state

more
less

@type —

s: number;

@return —

read(): number;
}
export class RleIntDiffDecoder extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, start: number)

Current state

more
less

@type —

s: number;
count: number;

@return —

read(): number;
}
export class UintOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
read(): number;
}
Referenced by
export class IncUintOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
read(): number;
}
export class IntDiffOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
diff: number;

@return —

read(): number;
}
export class StringDecoder {

@param —

constructor(uint8Array: Uint8Array)
str: string;

@type —

spos: number;

@return —

read(): string;
}
}
export * as diff from {
export function simpleDiffString(a: string, b: string): SimpleDiff<string>
export function simpleDiff(a: string, b: string): SimpleDiff<string>
export function simpleDiffArray<T>(a: T[], b: T[], compare?: (arg0: T, arg1: T) => boolean): SimpleDiff<T[]>
export function simpleDiffStringWithCursor(a: string, b: string, cursor: number): {
index: number;
remove: number;
insert: string;
}

A SimpleDiff describes a change on a String.

more
less
console.log(a) // the old value
console.log(b) // the updated value
// Apply changes of diff (pseudocode)
a.remove(diff.index, diff.remove) // Remove `diff.remove` characters
a.insert(diff.index, diff.insert) // Insert `diff.insert`
a === b // values match
export type SimpleDiff<T extends string | any[]> = {

The index where changes were applied

index: number;

The number of characters to delete starting at index.

remove: number;

The new text to insert at index after applying

insert: T;
}
Referenced by
}
export * as dom from {
export function createElement(name: string): HTMLElement
export function createDocumentFragment(): DocumentFragment
export function createTextNode(text: string): Text
export function emitCustomEvent(el: HTMLElement, name: string, opts: Object): boolean
export function setAttributes(el: Element, attrs: Pair<string, string | boolean>[]): Element
export function setAttributesMap(el: Element, attrs: Map<string, string>): Element
export function fragment(children: Node[] | HTMLCollection): DocumentFragment
export function append(parent: Element, nodes: Node[]): Element
export function remove(el: HTMLElement): void
export function addEventListener(el: EventTarget, name: string, f: EventListener): void
export function removeEventListener(el: EventTarget, name: string, f: EventListener): void
export function addEventListeners(node: Node, listeners: Pair<string, EventListener>[]): Node
export function removeEventListeners(node: Node, listeners: Pair<string, EventListener>[]): Node
export function element(name: string, attrs?: Pair<string, string> | Pair<string, boolean>[], children?: Node[]): Element
export function canvas(width: number, height: number): HTMLCanvasElement
export function text(text: string): Text
export function pairToStyleString(pair: Pair<string, string>): string
export function pairsToStyleString(pairs: Pair<string, string>[]): string
export function mapToStyleString(m: Map<string, string>): string
export function querySelector(el: HTMLElement | ShadowRoot, query: string): HTMLElement | null
export function querySelectorAll(el: HTMLElement | ShadowRoot, query: string): NodeListOf<HTMLElement>
export function getElementById(id: string): HTMLElement
export function parseFragment(html: string): DocumentFragment
export function parseElement(html: string): HTMLElement
export function replaceWith(oldEl: HTMLElement, newEl: HTMLElement | DocumentFragment): void
export function insertBefore(parent: HTMLElement, el: HTMLElement, ref: Node | null): HTMLElement
export function appendChild(parent: Node, child: Node): Node
export function checkNodeType(node: any, type: number): boolean
export function isParentOf(parent: Node, child: HTMLElement): boolean

@type —

export const doc: Document = ...

@type —

export const $fragment: Schema<DocumentFragment> = ...
export const domParser: DOMParser = ...

@type —

export const $element: Schema<Element> = ...

@type —

export const $text: Schema<Text> = ...
export const ELEMENT_NODE: 1 = ...
export const TEXT_NODE: 3 = ...
export const CDATA_SECTION_NODE: 4 = ...
export const COMMENT_NODE: 8 = ...
export const DOCUMENT_NODE: 9 = ...
export const DOCUMENT_TYPE_NODE: 10 = ...
export const DOCUMENT_FRAGMENT_NODE: 11 = ...

@type —

export const $node: Schema<Node> = ...
}
export * as encoding from {
export function createEncoder(): Encoder
export function encode(f: (arg0: Encoder) => void): Uint8Array<ArrayBuffer>
export function length(encoder: Encoder): number
export function hasContent(encoder: Encoder): boolean
export function toUint8Array(encoder: Encoder): Uint8Array<ArrayBuffer>
export function verifyLen(encoder: Encoder, len: number): void
export function write(encoder: Encoder, num: number): void
export function set(encoder: Encoder, pos: number, num: number): void
export function writeUint8(encoder: Encoder, num: number): void
export function setUint8(encoder: Encoder, pos: number, num: number): void
export function writeUint16(encoder: Encoder, num: number): void
export function setUint16(encoder: Encoder, pos: number, num: number): void
export function writeUint32(encoder: Encoder, num: number): void
export function writeUint32BigEndian(encoder: Encoder, num: number): void
export function setUint32(encoder: Encoder, pos: number, num: number): void
export function writeVarUint(encoder: Encoder, num: number): void
export function writeVarInt(encoder: Encoder, num: number): void
export function _writeVarStringNative(encoder: Encoder, str: string): void
export function _writeVarStringPolyfill(encoder: Encoder, str: string): void
export function writeVarString(encoder: Encoder, str: string): void
export function writeTerminatedString(encoder: Encoder, str: string): void
export function writeTerminatedUint8Array(encoder: Encoder, buf: Uint8Array): void
export function writeBinaryEncoder(encoder: Encoder, append: Encoder): void
export function writeUint8Array(encoder: Encoder, uint8Array: Uint8Array): void
export function writeVarUint8Array(encoder: Encoder, uint8Array: Uint8Array): void
export function writeOnDataView(encoder: Encoder, len: number): DataView
export function writeFloat32(encoder: Encoder, num: number): void
export function writeFloat64(encoder: Encoder, num: number): void
export function writeBigInt64(encoder: Encoder, num: bigint): any
export function writeBigUint64(encoder: Encoder, num: bigint): any
export function writeAny(encoder: Encoder, data: AnyEncodable): void

Now come a few stateful encoder that have their own classes.

more
less

Basic Run Length Encoder - a basic compression implementation.

Encodes [1,1,1,7] to [1,3,7,1] (3 times 1, 1 time 7). This encoder might do more harm than good if there are a lot of values that are not repeated.

It was originally used for image compression. Cool .. article http://csbruce.com/cbm/transactor/pdfs/trans_v7_i06.pdf

@note — T must not be null!

@template —

export class RleEncoder<T> extends Encoder {

@param —

constructor(writer: (arg0: Encoder, arg1: T) => void)

The writer

w: (arg0: Encoder, arg1: T) => void;

Current state

more
less

@type —

s: T | null;
count: number;

@param —

write(v: T): void;
}

Basic diff decoder using variable length encoding.

more
less

Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.

export class IntDiffEncoder extends Encoder {

@param —

constructor(start: number)

Current state

more
less

@type —

s: number;

@param —

write(v: number): void;
}

A combination of IntDiffEncoder and RleEncoder.

more
less

Basically first writes the IntDiffEncoder and then counts duplicate diffs using RleEncoding.

Encodes the values [1,1,1,2,3,4,5,6] as [1,1,0,2,1,5] (RLE([1,0,0,1,1,1,1,1]) ⇒ RleIntDiff[1,1,0,2,1,5])

export class RleIntDiffEncoder extends Encoder {

@param —

constructor(start: number)

Current state

more
less

@type —

s: number;
count: number;

@param —

write(v: number): void;
}

Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.

more
less

Internally uses VarInt encoder to write unsigned integers. If the input occurs multiple times, we write write it as a negative number. The UintOptRleDecoder then understands that it needs to read a count.

Encodes [1,2,3,3,3] as [1,2,-3,3] (once 1, once 2, three times 3)

export class UintOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}
Referenced by

Increasing Uint Optimized RLE Encoder

more
less

The RLE encoder counts the number of same occurences of the same value. The IncUintOptRle encoder counts if the value increases. I.e. 7, 8, 9, 10 will be encoded as [-7, 4]. 1, 3, 5 will be encoded as [1, 3, 5].

export class IncUintOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}

A combination of the IntDiffEncoder and the UintOptRleEncoder.

more
less

The count approach is similar to the UintDiffOptRleEncoder, but instead of using the negative bitflag, it encodes in the LSB whether a count is to be read. Therefore this Encoder only supports 31 bit integers!

Encodes [1, 2, 3, 2] as [3, 1, 6, -1] (more specifically [(1 << 1) | 1, (3 << 0) | 0, -1])

Internally uses variable length encoding. Contrary to normal UintVar encoding, the first byte contains:

  • 1 bit that denotes whether the next value is a count (LSB)
  • 1 bit that denotes whether this value is negative (MSB - 1)
  • 1 bit that denotes whether to continue reading the variable length integer (MSB)

Therefore, only five bits remain to encode diff ranges.

Use this Encoder only when appropriate. In most cases, this is probably a bad idea.

export class IntDiffOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;
diff: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}

Optimized String Encoder.

more
less

Encoding many small strings in a simple Encoder is not very efficient. The function call to decode a string takes some time and creates references that must be eventually deleted. In practice, when decoding several million small strings, the GC will kick in more and more often to collect orphaned string objects (or maybe there is another reason?).

This string encoder solves the above problem. All strings are concatenated and written as a single string using a single encoding call.

The lengths are encoded using a UintOptRleEncoder.

export class StringEncoder {

@type —

sarr: string[];
s: string;

@param —

write(string: string): void;
toUint8Array(): Uint8Array<ArrayBuffer>;
}
export type AnyEncodableArray = AnyEncodable[]
Referenced by
export type AnyEncodable = undefined | null | number | bigint | boolean | string | {
[key: string]: AnyEncodable;
} | AnyEncodableArray | Uint8Array
Referenced by
}
export * as environment from {
export function hasParam(name: string): boolean
export function getParam(name: string, defaultVal: string): string
export function getVariable(name: string): string | null
export function getConf(name: string): string | null
export function ensureConf(name: string): string
export function hasConf(name: string): boolean
export const isNode: boolean = ...
export const isBrowser: boolean = ...
export const isMac: boolean = ...
export const production: boolean = ...

Color is enabled by default if the terminal supports it.

more
less

Explicitly enable color using --color parameter Disable color using --no-color parameter or using NO_COLOR=1 environment variable. FORCE_COLOR=1 enables color and takes precedence over all.

export const supportsColor: boolean = ...
}
export * as error from {
export function create(s: string): Error
export function methodUnimplemented(): never
export function unexpectedCase(): never
export function assert(property: boolean): asserts property is true
}
export * as eventloop from {
export function enqueue(f: () => void): void
export function timeout(timeout: number, callback: Function): TimeoutObject
export function interval(timeout: number, callback: Function): TimeoutObject
export function animationFrame(cb: (arg0: number) => void): TimeoutObject
export function idleCallback(cb: Function): TimeoutObject
export function createDebouncer(timeout: number, triggerAfter?: number): (cb: ((...args: any) => void) | null) => void
export const Animation: {
new (timeoutId: number): {
_: number;
destroy(): void;
};
} = ...
export type TimeoutObject = {
destroy: Function;
}
Referenced by
}
export * as func from {
export function callAll(fs: Function[], args: any[], i?: number): void
export function nop(): void
export function apply<T>(f: () => T): T
export function id<A>(a: A): A
export function equalityStrict<T>(a: T, b: T): boolean
export function equalityFlat<T>(a: T[] | object, b: T[] | object): boolean
export function equalityDeep(a: any, b: any): boolean
export function isOneOf<V, OPTS extends V>(value: V, options: OPTS[]): boolean
export function isString(s: any): s is string
export function isNumber(n: any): n is number
export function is<TYPE extends new (...args: any) => any>(n: any, T: TYPE): n is InstanceType<TYPE>
export function isTemplate<TYPE extends new (...args: any) => any>(T: TYPE): (n: any) => n is InstanceType<TYPE>
export const isArray: (arg: any) => arg is any[] = ...
}
export * as indexeddb from {
export function rtop(request: IDBRequest): Promise<any>
export function openDB(name: string, initDB: (arg0: IDBDatabase) => any): Promise<IDBDatabase>
export function deleteDB(name: string): Promise<any>
export function createStores(db: IDBDatabase, definitions: string[] | string | IDBObjectStoreParameters | undefined[][]): void
export function transact(db: IDBDatabase, stores: string[], access?: "readwrite" | "readonly"): IDBObjectStore[]
export function count(store: IDBObjectStore, range?: IDBKeyRange): Promise<number>
export function get(store: IDBObjectStore, key: string | number | ArrayBuffer | Date | any[]): Promise<string | number | ArrayBuffer | Date | any[]>
export function del(store: IDBObjectStore, key: string | number | ArrayBuffer | Date | IDBKeyRange | any[]): Promise<any>
export function put(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key?: string | number | ArrayBuffer | Date | any[]): Promise<any>
export function add(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key: string | number | ArrayBuffer | Date | any[]): Promise<any>
export function addAutoKey(store: IDBObjectStore, item: string | number | ArrayBuffer | Date): Promise<number>
export function getAll(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>
export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>
export function queryFirst(store: IDBObjectStore, query: IDBKeyRange | null, direction: "next" | "prev" | "nextunique" | "prevunique"): Promise<any>
export function getLastKey(store: IDBObjectStore, range?: IDBKeyRange | null): Promise<any>
export function getFirstKey(store: IDBObjectStore, range?: IDBKeyRange | null): Promise<any>
export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<KeyValuePair[]>
export function iterate(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any, arg1: any) => void | boolean | Promise<void | boolean>, direction?: "next" | "prev" | "nextunique" | "prevunique"): Promise<void>
export function iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any) => void | boolean | Promise<void | boolean>, direction?: "next" | "prev" | "nextunique" | "prevunique"): Promise<void>
export function getStore(t: IDBTransaction, store: string): IDBObjectStore
export function createIDBKeyRangeBound(lower: any, upper: any, lowerOpen: boolean, upperOpen: boolean): IDBKeyRange
export function createIDBKeyRangeUpperBound(upper: any, upperOpen: boolean): IDBKeyRange
export function createIDBKeyRangeLowerBound(lower: any, lowerOpen: boolean): IDBKeyRange
export type KeyValuePair = {

key

k: any;

Value

v: any;
}
Referenced by
}
export * as iterator from {
export function mapIterator<T, R>(iterator: Iterator<T>, f: (arg0: T) => R): IterableIterator<R>
export function createIterator<T>(next: () => IteratorResult<T>): IterableIterator<T>
export function iteratorFilter<T>(iterator: Iterator<T>, filter: (arg0: T) => boolean): IterableIterator<T>
export function iteratorMap<T, M>(iterator: Iterator<T>, fmap: (arg0: T) => M): IterableIterator<M | undefined>
}

JSON utility functions.

export * as json from {

Transform JavaScript object to JSON.

more
less

@param —

@return —

export const stringify: {
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
} = ...

Parse JSON object.

more
less

@param —

@return —

export const parse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any = ...
}
export * as logging from {
export function print(...args: string | Symbol | Object | number | undefined[]): void
export function warn(...args: string | Symbol | Object | number[]): void
export function printError(err: Error): void
export function printImg(_url: string, _height: number): void
export function printImgBase64(base64: string, height: number): void
export function group(...args: string | Symbol | Object | number[]): void
export function groupCollapsed(...args: string | Symbol | Object | number[]): void
export function groupEnd(): void
export function printDom(_createNode: () => Node): void
export function printCanvas(canvas: HTMLCanvasElement, height: number): void
export function createVConsole(_dom: Element): void
export function createModuleLogger(moduleName: string): (...args: any[]) => void
export const BOLD: symbol = ...
export const UNBOLD: symbol = ...
export const BLUE: symbol = ...
export const GREY: symbol = ...
export const GREEN: symbol = ...
export const RED: symbol = ...
export const PURPLE: symbol = ...
export const ORANGE: symbol = ...
export const UNCOLOR: symbol = ...
}
export * as map from {
export function create(): Map<any, any>
export function copy<K, V>(m: Map<K, V>): Map<K, V>
export function setIfUndefined<MAP extends Map<any, any>, CF extends MAP extends Map<any, infer V> ? () => V : unknown>(map: MAP, key: MAP extends Map<infer K, any> ? K : unknown, createT: CF): ReturnType<CF>
export function map<K, V, R>(m: Map<K, V>, f: (arg0: V, arg1: K) => R): R[]
export function any<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean
export function all<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean
export type GlobalMap<K, V> = Map<K, V>
}

Common Math expressions.

export * as math from {
export function add(a: number, b: number): number
export function min(a: number, b: number): number
export function max(a: number, b: number): number
export function exp10(exp: number): number
export function isNegativeZero(n: number): boolean
export const floor: (x: number) => number = ...
export const ceil: (x: number) => number = ...
export const abs: (x: number) => number = ...
export const imul: (x: number, y: number) => number = ...
export const round: (x: number) => number = ...
export const log10: (x: number) => number = ...
export const log2: (x: number) => number = ...
export const log: (x: number) => number = ...
export const sqrt: (x: number) => number = ...
export const isNaN: (number: unknown) => boolean = ...
export const pow: (x: number, y: number) => number = ...
export const sign: (x: number) => number = ...
}
export * as mutex from {
export function createMutex(): import("mutex").mutex
export type mutex = (cb: () => void, elseCb?: (() => void) | undefined) => any
Referenced by
}
export * as number from {
export function countBits(n: number): number
export const MAX_SAFE_INTEGER: number = ...
export const MIN_SAFE_INTEGER: number = ...
export const LOWEST_INT32: number = ...
export const HIGHEST_INT32: number = ...
export const HIGHEST_UINT32: number = ...
export const isInteger: (number: unknown) => boolean = ...
export const isNaN: (number: unknown) => boolean = ...
export const parseInt: (string: string, radix?: number) => number = ...
}
export * as object from {
export function create(): {
[key: string]: any;
}
export function isObject(o: any): o is {
[key: string]: any;
}
export function forEach<V_1>(obj: {
[key: string]: V_1;
}, f: (arg0: V_1, arg1: string) => any): void
export function map<R>(obj: {
[key: string]: any;
}, f: (arg0: any, arg1: string) => R): R[]
export function length(obj: {
[key: string]: any;
}): number
export function size(obj: {
[key: string]: any;
}): number
export function some<T extends {
[key: string | number | symbol]: any;
}>(obj: T, f: (v: T[keyof T], k: keyof T) => boolean): boolean
export function isEmpty(obj: Object | null | undefined): boolean
export function every<T extends {
[key: string | number | symbol]: any;
}>(obj: T, f: (v: T[keyof T], k: keyof T) => boolean): boolean
export function hasProperty(obj: any, key: string | number | symbol): boolean
export function equalFlat(a: {
[key: string]: any;
}, b: {
[key: string]: any;
}): boolean
export function deepFreeze<T extends unknown>(o: T): Readonly<T>
export function setIfUndefined<KV extends object, K extends keyof KV = keyof KV>(o: KV, key: K, createT: () => KV[K]): KV[K]

Object.assign

export const assign: {
<T extends {}, U>(target: T, source: U): T & U;
<T extends {}, U, V_1>(target: T, source1: U, source2: V_1): T & U & V_1;
<T extends {}, U, V_1, W>(target: T, source1: U, source2: V_1, source3: W): T & U & V_1 & W;
(target: object, ...sources: any[]): any;
} = ...

@param —

export const keys: {
(o: object): string[];
(o: {}): string[];
} = ...

@template —

more
less

@param —

@return —

export const values: {
<T>(o: {
[key: string]: T;
} | ArrayLike<T>): T[];
(o: {}): any[];
} = ...

Make an object immutable. This hurts performance and is usually not needed if you perform good coding practices.

export const freeze: {
<T extends Function>(f: T): T;
<T extends {
[key: string]: U | null | undefined | object;
}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
<T>(o: T): Readonly<T>;
} = ...
}

Working with value pairs.

export * as pair from {
export function create<L, R>(left: L, right: R): Pair<L, R>
export function createReversed<L, R>(right: R, left: L): Pair<L, R>
export function forEach<L, R>(arr: Pair<L, R>[], f: (arg0: L, arg1: R) => any): void
export function map<L, R, X>(arr: Pair<L, R>[], f: (arg0: L, arg1: R) => X): X[]

@template —

export class Pair<L, R> {

@param —

more
less

@param —

constructor(left: L, right: R)
left: L;
right: R;
}
Referenced by
}
export * as prng from {
export function create(seed: number): PRNG
export function bool(gen: PRNG): boolean
export function int53(gen: PRNG, min: number, max: number): number
export function uint53(gen: PRNG, min: number, max: number): number
export function int32(gen: PRNG, min: number, max: number): number
export function uint32(gen: PRNG, min: number, max: number): number
export function int31(gen: PRNG, min: number, max: number): number
export function real53(gen: PRNG): number
export function char(gen: PRNG): string
export function letter(gen: PRNG): string
export function word(gen: PRNG, minLen?: number, maxLen?: number): string
export function utf16Rune(gen: PRNG): string
export function utf16String(gen: PRNG, maxlen?: number): string
export function oneOf<T>(gen: PRNG, array: T[]): T
export function uint8Array(gen: PRNG, len: number): Uint8Array<ArrayBuffer>
export function uint16Array(gen: PRNG, len: number): Uint16Array
export function uint32Array(gen: PRNG, len: number): Uint32Array

Description of the function

more
less

@callback —

A random type generator.

@typedef —

export const DefaultPRNG: typeof Xoroshiro128plus = ...
Unexported symbols referenced here

This is a variant of xoroshiro128plus - the fastest full-period generator passing BigCrush without systematic failures.

more
less

This implementation follows the idea of the original xoroshiro128plus implementation, but is optimized for the JavaScript runtime. I.e.

  • The operations are performed on 32bit integers (the original implementation works with 64bit values).
  • The initial 128bit state is computed based on a 32bit seed and Xorshift32.
  • This implementation returns two 32bit values based on the 64bit value that is computed by xoroshiro128plus. Caution: The last addition step works slightly different than in the original implementation - the add carry of the first 32bit addition is not carried over to the last 32bit.

Reference implementation

class Xoroshiro128plus {

@param — Unsigned 32 bit number

constructor(seed: number)
seed: number;
state: Uint32Array<ArrayBuffer>;
_fresh: boolean;

@return — Float/Double in [0,1)

next(): number;
}
Referenced by

Description of the function

export type generatorNext = () => number
Referenced by
}
export * as promise from {
export function create<T>(f: (arg0: PromiseResolve<T>, arg1: (arg0: Error) => void) => any): Promise<T>
export function createEmpty(f: (arg0: () => void, arg1: (arg0: Error) => void) => void): Promise<void>
export function reject(reason?: Error): Promise<never>
export function resolve<T>(res: T | void): Promise<T | void>
export function resolveWith<T>(res: T): Promise<T>
export function until(timeout: number, check: () => boolean, intervalResolution?: number): Promise<void>
export function untilAsync(check: () => Promise<boolean> | boolean, timeout?: number, intervalResolution?: number): Promise<void>
export function wait(timeout: number): Promise<undefined>
export function isPromise(p: any): boolean

Promise.all wait for all promises in the array to resolve and return the result

more
less

@template —

@param —

@return —

export const all: {
<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
<T extends readonly unknown[] | []>(values: T): Promise<{
-readonly [P in keyof T]: Awaited<T[P]>;
}>;
} = ...
export type PromiseResolve<T> = (result?: T | PromiseLike<T> | undefined) => any
Referenced by
}
export * as set from {
export function create(): Set<any>
export function toArray<T>(set: Set<T>): T[]
export function first<T>(set: Set<T>): T | undefined
export function from<T>(entries: Iterable<T>): Set<T>
}
export * as sort from {
export function _insertionSort<T>(arr: T[], lo: number, hi: number, compare: (arg0: T, arg1: T) => number): void
export function insertionSort<T>(arr: T[], compare: (arg0: T, arg1: T) => number): void
export function quicksort<T>(arr: T[], compare: (arg0: T, arg1: T) => number): void
}
export * as statistics from {
export function median(arr: number[]): number
export function average(arr: number[]): number
}

Utility module to work with strings.

export * as string from {
export function trimLeft(s: string): string
export function fromCamelCase(s: string, separator: string): string
export function utf8ByteLength(str: string): number
export function _encodeUtf8Polyfill(str: string): Uint8Array<ArrayBuffer>
export function _encodeUtf8Native(str: string): Uint8Array<ArrayBuffer>
export function encodeUtf8(str: string): Uint8Array<ArrayBuffer>
export function _decodeUtf8Polyfill(buf: Uint8Array): string
export function _decodeUtf8Native(buf: Uint8Array): string
export function decodeUtf8(buf: Uint8Array): string
export function splice(str: string, index: number, remove: number, insert?: string): string
export function repeat(source: string, n: number): string
export function escapeHTML(str: string): string
export function unescapeHTML(str: string): string
export const fromCharCode: (...codes: number[]) => string = ...
export const fromCodePoint: (...codePoints: number[]) => string = ...

The largest utf16 character. Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)

export const MAX_UTF16_CHARACTER: string = ...
export const utf8TextEncoder: TextEncoder = ...
export let utf8TextDecoder: TextDecoder | null = ...
}

Utility module to work with EcmaScript Symbols.

export * as symbol from {
export function isSymbol(s: any): boolean

Return fresh symbol.

export const create: SymbolConstructor = ...
}
export * as time from {
export function getDate(): Date
export function humanizeDuration(d: number): string

Return current unix time.

more
less

@return —

export const getUnixTime: () => number = ...
}
export * as tree from {

This is a Red Black Tree implementation

more
less

@template —

export class Tree<K, V> {
root: any;
length: number;

@param —

findNext(id: K): V;

@param —

findPrev(id: K): V;

@param —

findNodeWithLowerBound(from: K): any;

@param —

findNodeWithUpperBound(to: K): any;

@return —

findSmallestNode(): V;

@param —

more
less

@return —

findWithLowerBound(from: K): V;

@param —

more
less

@return —

findWithUpperBound(to: K): V;

@param —

more
less

@param —

@param —

iterate(from: K, to: any, f: (arg0: V) => void): void;

@param —

more
less

@return —

find(id: K): V | null;

@param —

more
less

@return —

findNode(id: K): N<V> | null;

@param —

delete(id: K): void;
_fixDelete(n: any): void;
put(v: any): any;
_fixInsert(n: any): void;
}
Unexported symbols referenced here

@template —

class N<V> {

A created node is always red!

more
less

@param —

constructor(val: V)
val: V;
color: boolean;
_left: any;
_right: any;
_parent: any;
isRed(): boolean;
isBlack(): boolean;
redden(): this;
blacken(): this;
get grandparent(): any;
get parent(): any;
get sibling(): any;
set left(n: any);
get left(): any;
set right(n: any);
get right(): any;
rotateLeft(tree: any): void;
next(): any;
prev(): any;
rotateRight(tree: any): void;
getUncle(): any;
}
Referenced by
}
export * as websocket from {

@deprecated —

more
less

@extends —

export class WebsocketClient extends Observable<string> {

@param —

more
less

@param —

constructor(url: string, { binaryType }?: {
binaryType?: "arraybuffer" | "blob" | null | undefined;
})
url: string;

@type —

ws: WebSocket | null;
binaryType: "arraybuffer" | "blob" | null;
connected: boolean;
connecting: boolean;
unsuccessfulReconnects: number;
lastMessageReceived: number;

Whether to connect to other peers or not

more
less

@type —

shouldConnect: boolean;
_checkInterval: Timeout;

@param —

send(message: any): void;
disconnect(): void;
connect(): void;
}
}
}
module "array" {
export function last<L>(arr: ArrayLike<L>): L
export function create<C>(): C[]
export function copy<D>(a: D[]): D[]
export function appendTo<M>(dest: M[], src: M[]): void
export function every<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : any): boolean
export function some<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : never): boolean
export function equalFlat<ELEM>(a: ArrayLike<ELEM>, b: ArrayLike<ELEM>): boolean
export function flatten<ELEM>(arr: ELEM[][]): ELEM[]
export function unfold<T_1>(len: number, f: (arg0: number, arg1: T_1[]) => T_1): T_1[]
export function fold<T_1, RESULT>(arr: T_1[], seed: RESULT, folder: (arg0: RESULT, arg1: T_1, arg2: number) => RESULT): RESULT
export function unique<T_1>(arr: T_1[]): T_1[]
export function uniqueBy<T_1, M>(arr: ArrayLike<T_1>, mapper: (arg0: T_1) => M): T_1[]
export function map<ARR extends ArrayLike<any>, MAPPER extends (arg0: ARR extends ArrayLike<infer T_1> ? T_1 : never, arg1: number, arg2: ARR) => any>(arr: ARR, mapper: MAPPER): MAPPER extends (...args: any[]) => infer M ? M : never[]
export function bubblesortItem<T_1>(arr: T_1[], i: number, compareFn: (a: T_1, b: T_1) => number): number

Transforms something array-like to an actual Array.

more
less

@function —

@template —

@param —

@return —

export const from: {
<T_1>(arrayLike: ArrayLike<T_1>): T_1[];
<T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
<T_1>(iterable: Iterable<T_1> | ArrayLike<T_1>): T_1[];
<T_1, U>(iterable: Iterable<T_1> | ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
} = ...
export const isArray: (arg: any) => arg is any[] = ...
}

Binary data constants.

module "binary" {

n-th bit activated.

more
less

@type —

export const BIT1: number = ...
export const BIT2: 2 = ...
export const BIT3: 4 = ...
export const BIT4: 8 = ...
export const BIT5: 16 = ...
export const BIT6: 32 = ...
export const BIT7: 64 = ...
export const BIT8: 128 = ...
export const BIT9: 256 = ...
export const BIT10: 512 = ...
export const BIT11: 1024 = ...
export const BIT12: 2048 = ...
export const BIT13: 4096 = ...
export const BIT14: 8192 = ...
export const BIT15: 16384 = ...
export const BIT16: 32768 = ...
export const BIT17: 65536 = ...
export const BIT18: number = ...
export const BIT19: number = ...
export const BIT20: number = ...
export const BIT21: number = ...
export const BIT22: number = ...
export const BIT23: number = ...
export const BIT24: number = ...
export const BIT25: number = ...
export const BIT26: number = ...
export const BIT27: number = ...
export const BIT28: number = ...
export const BIT29: number = ...
export const BIT30: number = ...
export const BIT31: number = ...
export const BIT32: number = ...

First n bits activated.

more
less

@type —

export const BITS0: number = ...
export const BITS1: 1 = ...
export const BITS2: 3 = ...
export const BITS3: 7 = ...
export const BITS4: 15 = ...
export const BITS5: 31 = ...
export const BITS6: 63 = ...
export const BITS7: 127 = ...
export const BITS8: 255 = ...
export const BITS9: 511 = ...
export const BITS10: 1023 = ...
export const BITS11: 2047 = ...
export const BITS12: 4095 = ...
export const BITS13: 8191 = ...
export const BITS14: 16383 = ...
export const BITS15: 32767 = ...
export const BITS16: 65535 = ...
export const BITS17: number = ...
export const BITS18: number = ...
export const BITS19: number = ...
export const BITS20: number = ...
export const BITS21: number = ...
export const BITS22: number = ...
export const BITS23: number = ...
export const BITS24: number = ...
export const BITS25: number = ...
export const BITS26: number = ...
export const BITS27: number = ...
export const BITS28: number = ...
export const BITS29: number = ...
export const BITS30: number = ...

@type —

export const BITS31: number = ...

@type —

export const BITS32: number = ...
}
module "broadcastchannel" {
export function subscribe(room: string, f: (arg0: any, arg1: any) => any): (arg0: any, arg1: any) => any
export function unsubscribe(room: string, f: (arg0: any, arg1: any) => any): boolean
export function publish(room: string, data: any, origin?: any): void
export type Channel = {
subs: Set<(arg0: any, arg1: any) => any>;
bc: any;
}
}
module "buffer" {
export function createUint8ArrayFromLen(len: number): Uint8Array<ArrayBuffer>
export function createUint8ArrayViewFromArrayBuffer(buffer: ArrayBuffer, byteOffset: number, length: number): Uint8Array<ArrayBuffer>
export function createUint8ArrayFromArrayBuffer(buffer: ArrayBuffer): Uint8Array<ArrayBuffer>

@param —

more
less

@return —

export function toBase64(bytes: Uint8Array): string

@param —

more
less

@return —

export function fromBase64(s: string): Uint8Array<ArrayBuffer>
export function toBase64UrlEncoded(buf: Uint8Array): string
export function fromBase64UrlEncoded(base64: string): Uint8Array<ArrayBuffer>
export function toHexString(buf: Uint8Array): string
export function fromHexString(hex: string): Uint8Array<ArrayBuffer>
export function copyUint8Array(uint8Array: Uint8Array): Uint8Array
export function encodeAny(data: any): Uint8Array
export function decodeAny(buf: Uint8Array): any
export function shiftNBitsLeft(bs: Uint8Array, N: number): Uint8Array<ArrayBufferLike>
}
module "lib0/cache" {
export function removeStale<K, V>(cache: Cache<K, V>): number
export function set<K, V>(cache: Cache<K, V>, key: K, value: V): void
export function get<K, V>(cache: Cache<K, V>, key: K): V | undefined
export function refreshTimeout<K, V>(cache: Cache<K, V>, key: K): void
export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined
export function remove<K, V>(cache: Cache<K, V>, key: K): NonNullable<V> | undefined
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): Promise<V> | V
export function create(timeout: number): Cache<any, any>

@template —

export class Cache<K, V> {

@param —

constructor(timeout: number)
timeout: number;

@type —

_q: List<Entry<K, V>>;

@type —

_map: Map<K, Entry<K, V>>;
}
Referenced by
Unexported symbols referenced here

@template —

more
less

@implements —

class Entry<K, V> implements ListNode {

@param —

more
less

@param —

constructor(key: K, val: V | Promise<V>)

@type —

prev: this | null;

@type —

next: this | null;
created: number;
val: V | Promise<V>;
key: K;
}
Referenced by
}
module "lib0/component" {
export function define(name: string, constr: any, opts?: ElementDefinitionOptions): void
export function whenDefined(name: string): Promise<CustomElementConstructor>
export function createComponent<T>(name: string, { template, style, state: defaultState, onStateChange, childStates, attrs, listeners, slots }: CONF<T>): typeof Lib0Component
export function createComponentDefiner(definer: Function): () => any
export function defineListComponent(): any
export function defineLazyLoadingComponent(): any

@type —

export const registry: CustomElementRegistry = ...

@template —

export class Lib0Component<S> extends HTMLElement {

@param —

constructor(state?: S)

@type —

state: S | null;

@type —

_internal: any;

@param —

more
less

@param — Force that the state is rerendered even if state didn't change

setState(_state: S, _forceStateUpdate?: boolean): void;

@param —

updateState(_stateUpdate: any): void;
}
Referenced by
export type CONF<S> = {

Template for the shadow dom.

template?: string | null | undefined;

shadow dom style. Is only used when CONF.template is defined

style?: string | undefined;

Initial component state.

state?: S | undefined;

Called when the state changes.

onStateChange?: ((arg0: S, arg1: S | null, arg2: Lib0Component<S>) => void) | undefined;

maps from CSS-selector to transformer function. The first element that matches the CSS-selector receives state updates via the transformer function.

childStates?: {
[key: string]: (arg0: any, arg1: any) => Object;
} | undefined;

attrs-keys and state-keys should be camelCase, but the DOM uses kebap-case. I.e. attrs = { myAttr: 4 } is represeted as <my-elem my-attr="4" /> in the DOM

attrs?: {
[key: string]: "string" | "number" | "json" | "bool";
} | undefined;

Maps from dom-event-name to event listener.

listeners?: {
[key: string]: (arg0: CustomEvent, arg1: Lib0Component<any>) => boolean | void;
} | undefined;

Fill slots automatically when state changes. Maps from slot-name to slot-html.

slots?: ((arg0: S, arg1: S, arg2: Lib0Component<S>) => {
[key: string]: string;
}) | undefined;
}
Referenced by
}
module "conditions" {
export function undefinedToNull<T>(v: T | null | undefined): T | null
}
module "lib0/crypto/jwt" {
export function encodeJwt(privateKey: CryptoKey, payload: Object): PromiseLike<string>
export function verifyJwt(publicKey: CryptoKey, jwt: string): Promise<{
header: any;
payload: any;
}>
export function unsafeDecode(jwt: string): {
header: any;
payload: any;
}
}
module "lib0/crypto/aes-gcm" {
export function encrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>
export function decrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array>
export function importKeyJwk(jwk: any, { usages, extractable }?: {
usages?: Usages | undefined;
extractable?: boolean | undefined;
}): Promise<CryptoKey>
export function importKeyRaw(raw: Uint8Array<ArrayBuffer>, { usages, extractable }?: {
usages?: Usages | undefined;
extractable?: boolean | undefined;
}): Promise<CryptoKey>
export function deriveKey(secret: Uint8Array<ArrayBuffer> | string, salt: Uint8Array<ArrayBuffer> | string, { extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKey>
export type Usages = "encrypt" | "decrypt"[]
Referenced by
export function exportKeyJwk(key: CryptoKey): Promise<JsonWebKey>
export function exportKeyRaw(key: CryptoKey): Promise<Uint8Array<ArrayBuffer>>
}
module "lib0/delta" {
export function $insertOpWith<Content extends Fingerprintable>($content: Schema<Content>): Schema<AttrInsertOp<Content> | InsertOp<Content>>
export function $modifyOpWith<Modify extends DeltaAny>($content: Schema<Modify>): Schema<AttrModifyOp<Modify> | ModifyOp<Modify>>
export function clone<D extends DeltaAny>(d: D): D extends DeltaBuilder<infer NodeName_1, infer Attrs_1, infer Children_1, infer Text, infer Schema_1> ? DeltaBuilder<NodeName_1, Attrs_1, Children_1, Text, Schema_1> : never
export function $delta<NodeNameSchema extends Schema<string> | string | string[] = Schema<any>, AttrsSchema extends Schema<{
[key: string | number]: any;
}> | {
[key: string | number]: any;
} = Schema<{}>, ChildrenSchema extends unknown = Schema<never>, HasText extends boolean = false, Recursive extends boolean = false, Formats extends {
[key: string]: any;
} = {
[key: string]: any;
}>({ name, attrs, children, text, formats, recursive }: {
name?: NodeNameSchema | null | undefined;
attrs?: AttrsSchema | null | undefined;
children?: ChildrenSchema | null | undefined;
text?: HasText | undefined;
formats?: Formats | undefined;
recursive?: Recursive | undefined;
}): [Unwrap<ReadSchema<NodeNameSchema>>, Unwrap<ReadSchema<AttrsSchema>>, Unwrap<ReadSchema<ChildrenSchema>>] extends [infer NodeName_1, infer Attrs_1, infer Children_1] ? Schema<Delta<NodeName_1, Attrs_1, Children_1 | (Recursive extends true ? RecursiveDelta<NodeName_1, Attrs_1, Children_1, HasText extends true ? string : never> : never), HasText extends true ? string : never>> : never
export function _$delta<NodeNameSchema extends Schema<string> | string | string[] = Schema<any>, AttrsSchema extends Schema<{
[key: string | number]: any;
}> | {
[key: string | number]: any;
} = Schema<{}>, ChildrenSchema extends unknown = Schema<never>, HasText extends boolean = false, Recursive extends boolean = false>({ name, attrs, children, text, recursive }: {
name?: NodeNameSchema | null | undefined;
attrs?: AttrsSchema | null | undefined;
children?: ChildrenSchema | null | undefined;
text?: HasText | undefined;
recursive?: Recursive | undefined;
}): [Unwrap<ReadSchema<NodeNameSchema>>, Unwrap<ReadSchema<AttrsSchema>>, Unwrap<ReadSchema<ChildrenSchema>>] extends [infer NodeName_1, infer Attrs_1, infer Children_1] ? Schema<Delta<NodeName_1, Attrs_1, Children_1 | (Recursive extends true ? RecursiveDelta<NodeName_1, Attrs_1, Children_1, HasText extends true ? string : never> : never), HasText extends true ? string : never>> : never
export function mergeAttrs<T extends {
[key: string]: any;
}>(a: T | null, b: T | null): T | null
export function mergeDeltas<D extends DeltaAny | null>(a: D, b: D): D
export function random<D extends DeltaAny>(gen: PRNG, $d: Schema<D>): D extends Delta<infer NodeName_1, infer Attrs_1, infer Children_1, infer Text, infer Schema_1> ? DeltaBuilder<NodeName_1, Attrs_1, Children_1, Text, Schema_1> : never

@overload —

export function create(): DeltaBuilder<any, {}, never, never, null>

@template —

more
less

@overload —

export function create<NodeName extends string>(nodeName: NodeName): DeltaBuilder<NodeName, {}, never, never, null>

@template —

more
less

@template —

@overload —

export function create<NodeName extends string, Schema extends Schema<DeltaAny>>(nodeName: NodeName, schema: Schema): Schema extends Schema<Delta<infer N, infer Attrs_1, infer Children_1, infer Text, any>> ? DeltaBuilder<NodeName, Attrs_1, Children_1, Text, Schema> : never

@template —

more
less

@overload —

export function create<Schema extends Schema<DeltaAny>>(schema: Schema): Schema extends Schema<Delta<infer N, infer Attrs_1, infer Children_1, infer Text, any>> ? DeltaBuilder<N, Attrs_1, Children_1, Text, Schema> : never

@template —

more
less

@template —

@template —

@overload —

export function create<NodeName extends string, Attrs extends {
[key: string | number]: any;
} | null, Children extends any[] | string = never>(nodeName: NodeName, attrs: Attrs, children?: Children | undefined): DeltaBuilder<NodeName extends null ? any : NodeName, Attrs extends null ? {} : Attrs, Extract<Children, any[]> extends infer Ac[] ? (unknown extends Ac ? never : Ac) : never, Extract<Children, string>, null>
export function $text<$Embeds extends Schema<any>[] = any>(...$embeds: $Embeds): Schema<TextDelta<_AnyToNull<$Embeds> extends null ? never : ($Embeds extends Schema<infer $C>[] ? $C : never)>>
export function text<Schema_1 extends Schema<Delta<any, {}, any, any, null>> = Schema<Delta<any, {}, never, string, null>>>($schema?: Schema_1): Schema_1 extends Schema<Delta<infer N, infer Attrs_1, infer Children_1, infer Text, any>> ? DeltaBuilder<N, Attrs_1, Children_1, Text, Schema_1> : never
export function $array<$Children extends unknown>($children?: $Children): Schema<ArrayDelta<Unwrap<ReadSchema<$Children>>>>
export function array<$Schema extends Schema<ArrayDelta<any>> = never>($schema: $Schema): $Schema extends never ? ArrayDeltaBuilder<never> : DeltaBuilder<any, {}, never, never, $Schema>
export function $map<$Attrs extends {
[key: string | number]: any;
}>($attrs: Schema<$Attrs>): Schema<MapDelta<$Attrs>>
export function map<$Schema extends Schema<MapDelta<any>> | undefined = undefined>($schema?: $Schema): $Schema extends Schema<MapDelta<infer Attrs_1>> ? DeltaBuilder<any, Attrs_1, never, never, $Schema> : MapDeltaBuilder<{}>
export function diff<D extends DeltaAny>(d1: D, d2: NoInfer<D>): D extends Delta<infer N, infer Attrs_1, infer Children_1, infer Text, any> ? DeltaBuilder<N, Attrs_1, Children_1, Text, null> : never

@typedef —

more
less

@type —

export const $attribution: Schema<Attribution> = ...

@typedef —

more
less

@typedef —

@typedef —

@typedef —

@typedef —

@typedef —

@typedef —

@typedef —

@type —

export const $deltaMapChangeJson: Schema<DeltaAttrOpJSON> = ...
export class TextOp extends ListNode {

@param —

more
less

@param —

@param —

constructor(insert: string, format: FormattingAttributes | null, attribution: Attribution | null)

@readonly —

more
less

@type —

readonly insert: string;

@readonly —

more
less

@type —

readonly format: FormattingAttributes | null;
attribution: Attribution | null;

@type —

_fingerprint: string | null;

@param —

_updateInsert(newVal: string): void;
get type(): "insert";
get length(): number;
get fingerprint(): string;

Remove a part of the operation (similar to Array.splice)

more
less

@param —

@param —

_splice(offset: number, len: number): this;

@return —

toJSON(): DeltaListOpJSON;

@return —

clone(start?: number, end?: number): TextOp;

@param —

[equalityTrait.EqualityTraitSymbol](other: TextOp): boolean;
}
Referenced by

@template —

export class InsertOp<ArrayContent extends Fingerprintable> extends ListNode {

@param —

more
less

@param —

@param —

constructor(insert: ArrayContent[], format: FormattingAttributes | null, attribution: Attribution | null)

@readonly —

more
less

@type —

readonly insert: ArrayContent[];

@readonly —

more
less

@type —

readonly format: FormattingAttributes | null;

@readonly —

more
less

@type —

readonly attribution: Attribution | null;

@type —

_fingerprint: string | null;

@param —

_updateInsert(newVal: ArrayContent): void;
get type(): "insert";
get length(): number;

@param —

more
less

@return —

_modValue(i: number): Extract<ArrayContent, DeltaAny>;
get fingerprint(): string;

Remove a part of the operation (similar to Array.splice)

more
less

@param —

@param —

_splice(offset: number, len: number): this;

@return —

toJSON(): DeltaListOpJSON;

@return —

clone(start?: number, end?: number): InsertOp<ArrayContent>;

@param —

[equalityTrait.EqualityTraitSymbol](other: InsertOp<ArrayContent>): boolean;
}
Referenced by

@template —

more
less

@template —

export class DeleteOp<Children extends Fingerprintable = never, Text extends string = never> extends ListNode {

@param —

constructor(len: number)
delete: number;

@type —

prevValue: (Children | Text) extends never ? null : (Delta<any, {}, Children, Text> | null);

@type —

_fingerprint: string | null;
get type(): "delete";
get length(): number;
get fingerprint(): string;

Remove a part of the operation (similar to Array.splice)

more
less

@param —

@param —

_splice(_offset: number, len: number): this;

@return —

toJSON(): DeltaListOpJSON;
clone(start?: number, end?: number): DeleteOp<never, never>;

@param —

[equalityTrait.EqualityTraitSymbol](other: DeleteOp): boolean;
}
Referenced by
export class RetainOp extends ListNode {

@param —

more
less

@param —

@param —

constructor(retain: number, format: FormattingAttributes | null, attribution: Attribution | null)

@readonly —

more
less

@type —

readonly retain: number;

@readonly —

more
less

@type —

readonly format: FormattingAttributes | null;

@readonly —

more
less

@type —

readonly attribution: Attribution | null;

@type —

_fingerprint: string | null;
get type(): "retain";
get length(): number;
get fingerprint(): string;

Remove a part of the operation (similar to Array.splice)

more
less

@param —

@param —

_splice(_offset: number, len: number): this;

@return —

toJSON(): DeltaListOpJSON;
clone(start?: number, end?: number): RetainOp;

@param —

[equalityTrait.EqualityTraitSymbol](other: RetainOp): boolean;
}
Referenced by

Delta that can be applied on a YType Embed

more
less

@template —

export class ModifyOp<DTypes extends DeltaAny = DeltaAny> extends ListNode {

@param —

more
less

@param —

@param —

constructor(delta: DTypes, format: FormattingAttributes | null, attribution: Attribution | null)

@readonly —

more
less

@type —

readonly value: DTypes;

@readonly —

more
less

@type —

readonly format: FormattingAttributes | null;

@readonly —

more
less

@type —

readonly attribution: Attribution | null;

@type —

_fingerprint: string | null;
get type(): "modify";
get length(): number;
get _modValue(): DeltaBuilderAny;
get fingerprint(): string;

Remove a part of the operation (similar to Array.splice)

more
less

@param —

@param —

_splice(_offset: number, _len: number): this;

@return —

toJSON(): DeltaListOpJSON;

@return —

clone(): ModifyOp<DTypes>;

@param —

[equalityTrait.EqualityTraitSymbol](other: ModifyOp<any>): boolean;
}
Referenced by

@template —

more
less

@template —

export class AttrInsertOp<V extends Fingerprintable, K extends string | number = any> {

@param —

more
less

@param —

@param —

@param —

constructor(key: K, value: V, prevValue: V | undefined, attribution: Attribution | null)

@readonly —

more
less

@type —

readonly key: K;

@readonly —

more
less

@type —

readonly value: V;

@readonly —

more
less

@type —

readonly prevValue: V | undefined;

@readonly —

more
less

@type —

readonly attribution: Attribution | null;

@type —

_fingerprint: string | null;
get type(): "insert";
get _modValue(): DeltaBuilderAny;
get fingerprint(): string;
toJSON(): {
type: "insert";
value: V | DeltaJSON;
} & (({
attribution: Attribution;
} | {
attribution?: undefined;
}) & ({
prevValue: V & {};
} | {
prevValue?: undefined;
}));

@return —

clone(): AttrInsertOp<V, K>;

@param —

[equalityTrait.EqualityTraitSymbol](other: AttrInsertOp<V>): boolean;
}
Referenced by

@template —

more
less

@template —

export class AttrDeleteOp<V, K extends string | number = string> {

@param —

more
less

@param —

@param —

constructor(key: K, prevValue: V | undefined, attribution: Attribution | null)

@type —

key: K;

@type —

prevValue: V | undefined;
attribution: Attribution | null;

@type —

_fingerprint: string | null;
get value(): undefined;
get type(): "delete";
get fingerprint(): string;

@return —

toJSON(): DeltaAttrOpJSON;
clone(): AttrDeleteOp<V, K>;

@param —

[equalityTrait.EqualityTraitSymbol](other: AttrDeleteOp<V>): boolean;
}
Referenced by

@template —

more
less

@template —

export class AttrModifyOp<Modifier extends DeltaAny = DeltaAny, K extends string | number = string> {

@param —

more
less

@param —

constructor(key: K, delta: Modifier)

@readonly —

more
less

@type —

readonly key: K;

@readonly —

more
less

@type —

readonly value: Modifier;

@type —

_fingerprint: string | null;
get type(): "modify";
get fingerprint(): string;
get _modValue(): DeltaBuilder;

@return —

toJSON(): DeltaAttrOpJSON;

@return —

clone(): AttrModifyOp<Modifier, K>;

@param —

[equalityTrait.EqualityTraitSymbol](other: AttrModifyOp<Modifier>): boolean;
}
Referenced by

@type —

export const $deleteOp: Schema<AttrDeleteOp<any> | DeleteOp> = ...

@type —

export const $insertOp: Schema<AttrInsertOp<any> | InsertOp<any>> = ...

@type —

export const $textOp: Schema<TextOp> = ...

@type —

export const $retainOp: Schema<RetainOp> = ...

@type —

export const $modifyOp: Schema<AttrModifyOp | ModifyOp> = ...
export const $anyOp: Schema<AttrInsertOp<any, any> | InsertOp<any> | AttrDeleteOp<any, string> | DeleteOp<never, never> | TextOp | AttrModifyOp<DeltaAny, string> | ModifyOp<DeltaAny>> = ...

@template —

more
less

@template —

@typedef —

@template —

@template —

@template —

@typedef —

@template —

@template —

@typedef —

@template —

@typedef —

@template —

@typedef —

@typedef —

@typedef —

@template —

@template —

@template —

@template —

@template —

export class Delta<NodeName extends string = any, Attrs extends {
[key: string | number]: any;
} = {}, Children extends Fingerprintable = never, Text extends string = never, Schema extends Schema<Delta<any, any, any, any, any>> | null = any> {

@param —

more
less

@param —

constructor(name?: NodeName, $schema?: Schema)
name: NodeName | null;
$schema: NonNullable<Schema> | null;

@type —

attrs: {
[K in keyof Attrs]?: K extends string | number ? (AttrInsertOp<Attrs[K], K> | AttrDeleteOp<Attrs[K], K> | (Delta extends Attrs[K] ? AttrModifyOp<Extract<Attrs[K], DeltaAny>, K> : never)) : never;
} & {
[Symbol.iterator]: () => Iterator<{
[K in keyof Attrs]: K extends string | number ? (AttrInsertOp<Attrs[K], K> | AttrDeleteOp<Attrs[K], K> | (Delta extends Attrs[K] ? AttrModifyOp<Extract<Attrs[K], DeltaAny>, K> : never)) : never;
}[keyof Attrs]>;
};

@type —

children: List<RetainOp | DeleteOp | (Text extends never ? never : TextOp) | (Children extends never ? never : InsertOp<Children>) | (Delta extends Children ? ModifyOp<Extract<Children, Delta<any, any, any, any, any>>> : never)>;
childCnt: number;

@type —

origin: any;

@type —

_fingerprint: string | null;
isDone: boolean;
get fingerprint(): string;
isEmpty(): boolean;

@return —

toJSON(): DeltaJSON;

@param —

more
less

@return —

equals(other: Delta<any, any, any, any, any>): boolean;

@return —

clone(): DeltaBuilder<NodeName, Attrs, Children, Text, Schema>;

@param —

more
less

@param —

@return —

slice(start?: number, end?: number): DeltaBuilder<NodeName, Attrs, Children, Text, Schema>;

Mark this delta as done and perform some cleanup (e.g. remove appended retains without formats&attributions). In the future, there might be additional merge operations that can be performed to result in smaller deltas. Set markAsDone=false to only perform the cleanup.

more
less

@return —

done(markAsDone?: boolean): Delta<NodeName, Attrs, Children, Text, Schema>;
[fingerprintTrait.FingerprintTraitSymbol](): string;

@param —

more
less

@return —

[equalityTrait.EqualityTraitSymbol](other: any): boolean;
}
Referenced by

@template —

more
less

@template —

@template —

@template —

@template —

@extends —

export class DeltaBuilder<NodeName extends string = any, Attrs extends {
[key: string | number]: any;
} = {}, Children extends Fingerprintable = never, Text extends string = never, Schema extends Schema<Delta<any, any, any, any, any>> | null = any> extends Delta<NodeName, Attrs, Children, Text, Schema> {

@type —

usedAttributes: FormattingAttributes | null;

@type —

usedAttribution: Attribution | null;

@param —

useAttribution(attribution: Attribution | null): this;

@param —

more
less

@return —

useAttributes(attributes: FormattingAttributes | null): this;

@param —

more
less

@param —

updateUsedAttributes(name: string, value: any): this;

@template —

more
less

@param —

@param —

updateUsedAttribution<NAME extends keyof Attribution>(name: NAME, value: Attribution[NAME] | null): this;

@template —

more
less

@param —

@param —

@param —

@return —

insert<NewContent extends AllowedDeltaFromSchema<Schema> extends Delta<any, any, infer Children_1, infer Text_1, infer Schema_1> ? ((Children_1 extends never ? never : Children_1[]) | Text_1) : never>(insert: NewContent, formatting?: FormattingAttributes | null, attribution?: Attribution | null): DeltaBuilder<NodeName, Attrs, Exclude<NewContent, string>[number] | Children, (Extract<NewContent, string> | Text) extends never ? never : string, Schema>;

@template —

more
less

@param —

@param —

@param —

@return —

modify<NewContent extends AllowedDeltaFromSchema<Schema> extends Delta<any, any, infer Children_1, any, any> ? Extract<Children_1, Delta<any, any, any, any, any>> : never>(modify: NewContent, formatting?: FormattingAttributes | null, attribution?: Attribution | null): DeltaBuilder<NodeName, Attrs, Exclude<NewContent, string>[number] | Children, (Extract<NewContent, string> | Text) extends string ? string : never, Schema>;

@param —

more
less

@param —

@param —

retain(len: number, format?: FormattingAttributes | null, attribution?: Attribution | null): this;

@param —

delete(len: number): this;

@template —

more
less

@template —

@param —

@param —

@param —

@param —

@return —

set<Key extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer Attrs_1, any, any, any> ? (keyof Attrs_1) : never, Val extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer Attrs_1, any, any, any> ? (Attrs_1[Key]) : never>(key: Key, val: Val, attribution?: Attribution | null, prevValue?: Val | undefined): DeltaBuilder<NodeName, {
[K in keyof AddToAttrs<Attrs, Key, Val>]: AddToAttrs<Attrs, Key, Val>[K];
}, Children, Text, Schema>;

@template —

more
less

@param —

@param —

@return —

setMany<NewAttrs extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer Attrs_1, any, any, any> ? Attrs_1 : never>(attrs: NewAttrs, attribution?: Attribution | null): DeltaBuilder<NodeName, {
[K in keyof MergeAttrs<Attrs, NewAttrs>]: MergeAttrs<Attrs, NewAttrs>[K];
}, Children, Text, Schema>;

@template —

more
less

@param —

@param —

@param —

@return —

unset<Key extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer As, any, any, any> ? keyof As : never>(key: Key, attribution?: Attribution | null, prevValue?: any): DeltaBuilder<NodeName, {
[K in keyof AddToAttrs<Attrs, Key, never>]: AddToAttrs<Attrs, Key, never>[K];
}, Children, Text, Schema>;

@template —

more
less

@template —

@param —

@param —

@return —

update<Key extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer As, any, any, any> ? {
[K in keyof As]: Extract<As[K], Delta<any, any, any, any, any>> extends never ? never : K;
}[keyof As] : never, D extends AllowedDeltaFromSchema<Schema> extends Delta<any, infer As, any, any, any> ? Extract<As[Key], Delta<any, any, any, any, any>> : never>(key: Key, modify: D): DeltaBuilder<NodeName, {
[K in keyof AddToAttrs<Attrs, Key, D>]: AddToAttrs<Attrs, Key, D>[K];
}, Children, Text, Schema>;

@param —

apply(other: Delta<NodeName, Attrs, Children, Text, any>): this;

@param —

more
less

@param —

rebase(other: DeltaAny, priority: boolean): this;

Same as doing delta.rebase(other.inverse()), without creating a temporary delta.

more
less

@param —

@param —

rebaseOnInverse(other: DeltaAny, priority: boolean): this;

Append child ops from one op to the other.

more
less
delta.create().insert('a').append(delta.create().insert('b')) // => insert "ab"

@template —

@param —

@return —

append<OtherDelta extends DeltaAny>(other: OtherDelta): CastToDelta<OtherDelta> extends Delta<any, any, infer OtherChildren, infer OtherText, any> ? DeltaBuilder<NodeName, Attrs, Children | OtherChildren, Text | OtherText, Schema> : never;
}
Referenced by

@template —

more
less

@typedef —

@template —

@template —

@template —

@template —

@typedef —

@template —

@template —

@template —

@template —

@template —

@template —

@extends —

export class $Delta<Name extends string, Attrs extends {
[key: string | number]: any;
}, Children extends Fingerprintable, HasText extends boolean, Formats extends {
[key: string]: any;
}, Recursive extends boolean> extends Schema<Delta<Name, Attrs, Children | (Recursive extends true ? RecursiveDelta<Name, Attrs, Children, HasText extends true ? string : never> : never), HasText extends true ? string : never, any>> {

@param —

more
less

@param —

@param —

@param —

@param —

@param —

constructor($name: Schema<Name>, $attrs: Schema<Attrs>, $children: Schema<Children>, hasText: HasText, $formats: Schema<Formats>, recursive: Recursive)
shape: {
$name: Schema<Name>;
$attrs: Schema<Attrs> | Schema<Partial<$ObjectToType<{
[key: string]: Schema<any>;
[key: number]: Schema<any>;
[key: symbol]: Schema<any>;
}>>>;
$children: Schema<Children>;
hasText: HasText;
$formats: Schema<Formats>;
};
}
Referenced by
export const $$delta: Schema<$Delta<string, {
[key: string]: any;
[key: number]: any;
}, Fingerprintable, boolean, {
[key: string]: any;
}, boolean>> = ...

@type —

export const $deltaAny: Schema<DeltaAny> = ...

@type —

export const $deltaBuilderAny: Schema<DeltaBuilderAny> = ...
export const $textOnly: Schema<TextDelta<unknown>> = ...
export type Attribution = {
insert?: string[];
insertAt?: number;
delete?: string[];
deleteAt?: number;
format?: Record<string, string[]>;
formatAt?: number;
}
Referenced by
export type DeltaOps = Unwrap<Schema<AttrInsertOp<any, any> | InsertOp<any> | AttrDeleteOp<any, string> | DeleteOp<never, never> | TextOp | AttrModifyOp<DeltaAny, string> | ModifyOp<DeltaAny>>>
export type FormattingAttributes = {
[key: string]: any;
}
Referenced by
export type DeltaJSON = {
type: "delta";
name?: string;
attrs?: {
[Key in string | number]: DeltaAttrOpJSON;
};
children?: DeltaListOpJSON[];
}
Referenced by
export type DeltaListOpJSON = {
type: "insert";
insert: string | any[];
format?: {
[key: string]: any;
};
attribution?: Attribution;
} | {
delete: number;
} | {
type: "retain";
retain: number;
format?: {
[key: string]: any;
};
attribution?: Attribution;
} | {
type: "modify";
value: object;
}
Referenced by
export type DeltaAttrOpJSON = {
type: "insert";
value: any;
prevValue?: any;
attribution?: Attribution;
} | {
type: "delete";
prevValue?: any;
attribution?: Attribution;
} | {
type: "modify";
value: DeltaJSON;
}
Referenced by
export type ChildrenOpAny = TextOp | InsertOp<any> | DeleteOp | RetainOp | ModifyOp<any>
Referenced by
export type AttrOpAny = AttrInsertOp<any> | AttrDeleteOp<any> | AttrModifyOp
Referenced by
export type _OpAny = ChildrenOpAny | AttrOpAny
export type MergeListArrays<C1 extends any[] | string, C2 extends any[] | string> = Extract<C1 | C2, any[]> extends never ? never : ((Extract<C1 | C2, any[]> extends infer AC1[] ? (unknown extends AC1 ? never : AC1) : never)[])
export type AddToAttrs<Attrs_1 extends {
[Key in string | number]: any;
}, Key extends string | number, Val extends unknown> = {
[K in (Key | keyof Attrs_1)]: (unknown extends Attrs_1[K] ? never : Attrs_1[K]) | (Key extends K ? Val : never);
}
Referenced by
export type MergeAttrs<Attrs_1 extends {
[Key in string | number | symbol]: any;
}, NewAttrs extends {
[Key in string | number | symbol]: any;
}> = {
[K in (keyof NewAttrs | keyof Attrs_1)]: (unknown extends Attrs_1[K] ? never : Attrs_1[K]) | (unknown extends NewAttrs[K] ? never : NewAttrs[K]);
}
Referenced by
export type _AnyToNull<X> = 0 extends (1 & X) ? null : X
Referenced by
export type AllowedDeltaFromSchema<Schema_1 extends Schema<Delta<any, any, any, any, any>> | null> = _AnyToNull<Schema_1> extends null ? Delta<any, {
[key: string | number]: any;
}, any, string> : (Schema_1 extends Schema<infer D> ? D : never)
Referenced by
export type DeltaBuilderAny = DeltaBuilder<any, {
[key: string | number]: any;
}, any, any, any>
Referenced by
export type CastToDelta<D extends DeltaAny> = D extends DeltaBuilder<infer N, infer Attrs_1, infer Children_1, infer Text, infer Schema_1> ? Delta<N, Attrs_1, Children_1, Text, Schema_1> : D
Referenced by
export type RecursiveDelta<NodeName_1 extends string, Attrs_1 extends {
[key: string | number]: any;
} = {}, Children_1 extends Fingerprintable | never = never, Text extends string | never = never> = Delta<NodeName_1, Attrs_1, Children_1 | Delta<NodeName_1, Attrs_1, Children_1, Text> | RecursiveDelta<NodeName_1, Attrs_1, Children_1, Text>, Text>
Referenced by
export type TextDelta<Embeds extends Fingerprintable = never> = Delta<any, {}, Embeds, string>
Referenced by
export type TextDeltaBuilder<Embeds extends Fingerprintable = never> = DeltaBuilder<any, {}, Embeds, string>
export type ArrayDelta<Children_1 extends Fingerprintable> = Delta<any, {}, Children_1, never>
Referenced by
export type ArrayDeltaBuilder<Children_1 extends Fingerprintable> = DeltaBuilder<any, {}, Children_1, never>
Referenced by
export type MapDelta<Attrs_1 extends {
[key: string | number]: any;
}> = Delta<any, Attrs_1, never, never>
Referenced by
export type MapDeltaBuilder<Attrs_1 extends {
[key: string | number]: any;
}> = DeltaBuilder<any, Attrs_1, never, never>
Referenced by
}
module "lib0/crypto/ecdsa" {
export function sign(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array<ArrayBuffer>>
export function verify(key: CryptoKey, signature: Uint8Array<ArrayBuffer>, data: Uint8Array<ArrayBuffer>): PromiseLike<boolean>
export function generateKeyPair({ extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKeyPair>
export function importKeyJwk(jwk: any, { extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKey>
export function importKeyRaw(raw: any, { extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKey>
export type Usages = "sign" | "verify"[]
Referenced by
}
module "lib0/crypto/rsa-oaep" {
export function encrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array<ArrayBuffer>>
export function decrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array>
export function generateKeyPair({ extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKeyPair>
export function importKeyJwk(jwk: any, { extractable, usages }?: {
extractable?: boolean | undefined;
usages?: Usages | undefined;
}): Promise<CryptoKey>
export type Usages = "encrypt" | "decrypt"[]
Referenced by
}
module "lib0/hash/rabin" {
export function fingerprint(irreducible: Uint8Array, data: Uint8Array): Uint8Array<ArrayBuffer>
export const StandardIrreducible8: Uint8Array<ArrayBuffer> = ...
export const StandardIrreducible16: Uint8Array<ArrayBuffer> = ...
export const StandardIrreducible32: Uint8Array<ArrayBuffer> = ...
export const StandardIrreducible64: Uint8Array<ArrayBuffer> = ...
export const StandardIrreducible128: Uint8Array<ArrayBuffer> = ...
export class RabinEncoder {

@param — assert(m[0] === 1)

constructor(m: Uint8Array)
m: Uint8Array<ArrayBufferLike>;
blen: number;
bs: Uint8Array<ArrayBuffer>;
cache: Uint8Array<ArrayBuffer>;

This describes the position of the most significant byte (starts with 0 and increases with shift)

bpos: number;

@param —

write(byte: number): void;
getFingerprint(): Uint8Array<ArrayBuffer>;
}
}
module "lib0/hash/sha256" {
export function digest(data: Uint8Array): Uint8Array<ArrayBuffer>
}
module "decoding" {
export function createDecoder<Buf extends ArrayBufferLike>(uint8Array: Uint8Array<Buf>): Decoder<Buf>
export function hasContent(decoder: Decoder): boolean
export function clone(decoder: Decoder, newPos?: number): Decoder
export function readUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>, len: number): Uint8Array<Buf>
export function readVarUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>): Uint8Array<Buf>
export function readTailAsUint8Array(decoder: Decoder): Uint8Array
export function skip8(decoder: Decoder): number
export function readUint8(decoder: Decoder): number
export function readUint16(decoder: Decoder): number
export function readUint32(decoder: Decoder): number
export function readUint32BigEndian(decoder: Decoder): number
export function peekUint8(decoder: Decoder): number
export function peekUint16(decoder: Decoder): number
export function peekUint32(decoder: Decoder): number
export function readVarUint(decoder: Decoder): number
export function readVarInt(decoder: Decoder): number
export function peekVarUint(decoder: Decoder): number
export function peekVarInt(decoder: Decoder): number
export function _readVarStringPolyfill(decoder: Decoder): string
export function _readVarStringNative(decoder: Decoder): string
export function readVarString(decoder: Decoder): string
export function readTerminatedUint8Array(decoder: Decoder): Uint8Array
export function readTerminatedString(decoder: Decoder): string
export function peekVarString(decoder: Decoder): string
export function readFromDataView(decoder: Decoder, len: number): DataView
export function readFloat32(decoder: Decoder): number
export function readFloat64(decoder: Decoder): number
export function readBigInt64(decoder: Decoder): any
export function readBigUint64(decoder: Decoder): any
export function readAny(decoder: Decoder): any

A Decoder handles the decoding of an Uint8Array.

more
less

@template —

export class Decoder<Buf extends ArrayBufferLike = ArrayBufferLike> {

@param — Binary data to decode

constructor(uint8Array: Uint8Array<Buf>)

Decoding target.

more
less

@type —

arr: Uint8Array<Buf>;

Current decoding position.

more
less

@type —

pos: number;
}
Referenced by

T must not be null.

more
less

@template —

export class RleDecoder<T> extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, reader: (arg0: Decoder) => T)

The reader

reader: (arg0: Decoder) => T;

Current state

more
less

@type —

s: T | null;
count: number;
read(): T;
}
export class IntDiffDecoder extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, start: number)

Current state

more
less

@type —

s: number;

@return —

read(): number;
}
export class RleIntDiffDecoder extends Decoder<ArrayBufferLike> {

@param —

more
less

@param —

constructor(uint8Array: Uint8Array, start: number)

Current state

more
less

@type —

s: number;
count: number;

@return —

read(): number;
}
export class UintOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
read(): number;
}
Referenced by
export class IncUintOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
read(): number;
}
export class IntDiffOptRleDecoder extends Decoder<ArrayBufferLike> {

@param —

constructor(uint8Array: Uint8Array)

@type —

s: number;
count: number;
diff: number;

@return —

read(): number;
}
export class StringDecoder {

@param —

constructor(uint8Array: Uint8Array)
str: string;

@type —

spos: number;

@return —

read(): string;
}
}
module "lib0/diff/patience" {
export function diff(as: string[], bs: string[]): {
index: number;
remove: string[];
insert: string[];
}[]
export function diffSplitBy(a: string, b: string, _regexp: RegExp | string): {
index: number;
remove: string;
insert: string;
}[]
export function diffAuto(a: string, b: string): {
insert: string;
remove: string;
index: number;
}[]
}
module "diff" {
export function simpleDiffString(a: string, b: string): SimpleDiff<string>
export function simpleDiff(a: string, b: string): SimpleDiff<string>
export function simpleDiffArray<T>(a: T[], b: T[], compare?: (arg0: T, arg1: T) => boolean): SimpleDiff<T[]>
export function simpleDiffStringWithCursor(a: string, b: string, cursor: number): {
index: number;
remove: number;
insert: string;
}

A SimpleDiff describes a change on a String.

more
less
console.log(a) // the old value
console.log(b) // the updated value
// Apply changes of diff (pseudocode)
a.remove(diff.index, diff.remove) // Remove `diff.remove` characters
a.insert(diff.index, diff.insert) // Insert `diff.insert`
a === b // values match
export type SimpleDiff<T extends string | any[]> = {

The index where changes were applied

index: number;

The number of characters to delete starting at index.

remove: number;

The new text to insert at index after applying

insert: T;
}
Referenced by
}
module "dom" {
export function createElement(name: string): HTMLElement
export function createDocumentFragment(): DocumentFragment
export function createTextNode(text: string): Text
export function emitCustomEvent(el: HTMLElement, name: string, opts: Object): boolean
export function setAttributes(el: Element, attrs: Pair<string, string | boolean>[]): Element
export function setAttributesMap(el: Element, attrs: Map<string, string>): Element
export function fragment(children: Node[] | HTMLCollection): DocumentFragment
export function append(parent: Element, nodes: Node[]): Element
export function remove(el: HTMLElement): void
export function addEventListener(el: EventTarget, name: string, f: EventListener): void
export function removeEventListener(el: EventTarget, name: string, f: EventListener): void
export function addEventListeners(node: Node, listeners: Pair<string, EventListener>[]): Node
export function removeEventListeners(node: Node, listeners: Pair<string, EventListener>[]): Node
export function element(name: string, attrs?: Pair<string, string> | Pair<string, boolean>[], children?: Node[]): Element
export function canvas(width: number, height: number): HTMLCanvasElement
export function text(text: string): Text
export function pairToStyleString(pair: Pair<string, string>): string
export function pairsToStyleString(pairs: Pair<string, string>[]): string
export function mapToStyleString(m: Map<string, string>): string
export function querySelector(el: HTMLElement | ShadowRoot, query: string): HTMLElement | null
export function querySelectorAll(el: HTMLElement | ShadowRoot, query: string): NodeListOf<HTMLElement>
export function getElementById(id: string): HTMLElement
export function parseFragment(html: string): DocumentFragment
export function parseElement(html: string): HTMLElement
export function replaceWith(oldEl: HTMLElement, newEl: HTMLElement | DocumentFragment): void
export function insertBefore(parent: HTMLElement, el: HTMLElement, ref: Node | null): HTMLElement
export function appendChild(parent: Node, child: Node): Node
export function checkNodeType(node: any, type: number): boolean
export function isParentOf(parent: Node, child: HTMLElement): boolean

@type —

export const doc: Document = ...

@type —

export const $fragment: Schema<DocumentFragment> = ...
export const domParser: DOMParser = ...

@type —

export const $element: Schema<Element> = ...

@type —

export const $text: Schema<Text> = ...
export const ELEMENT_NODE: 1 = ...
export const TEXT_NODE: 3 = ...
export const CDATA_SECTION_NODE: 4 = ...
export const COMMENT_NODE: 8 = ...
export const DOCUMENT_NODE: 9 = ...
export const DOCUMENT_TYPE_NODE: 10 = ...
export const DOCUMENT_FRAGMENT_NODE: 11 = ...

@type —

export const $node: Schema<Node> = ...
}
module "encoding" {
export function createEncoder(): Encoder
export function encode(f: (arg0: Encoder) => void): Uint8Array<ArrayBuffer>
export function length(encoder: Encoder): number
export function hasContent(encoder: Encoder): boolean
export function toUint8Array(encoder: Encoder): Uint8Array<ArrayBuffer>
export function verifyLen(encoder: Encoder, len: number): void
export function write(encoder: Encoder, num: number): void
export function set(encoder: Encoder, pos: number, num: number): void
export function writeUint8(encoder: Encoder, num: number): void
export function setUint8(encoder: Encoder, pos: number, num: number): void
export function writeUint16(encoder: Encoder, num: number): void
export function setUint16(encoder: Encoder, pos: number, num: number): void
export function writeUint32(encoder: Encoder, num: number): void
export function writeUint32BigEndian(encoder: Encoder, num: number): void
export function setUint32(encoder: Encoder, pos: number, num: number): void
export function writeVarUint(encoder: Encoder, num: number): void
export function writeVarInt(encoder: Encoder, num: number): void
export function _writeVarStringNative(encoder: Encoder, str: string): void
export function _writeVarStringPolyfill(encoder: Encoder, str: string): void
export function writeVarString(encoder: Encoder, str: string): void
export function writeTerminatedString(encoder: Encoder, str: string): void
export function writeTerminatedUint8Array(encoder: Encoder, buf: Uint8Array): void
export function writeBinaryEncoder(encoder: Encoder, append: Encoder): void
export function writeUint8Array(encoder: Encoder, uint8Array: Uint8Array): void
export function writeVarUint8Array(encoder: Encoder, uint8Array: Uint8Array): void
export function writeOnDataView(encoder: Encoder, len: number): DataView
export function writeFloat32(encoder: Encoder, num: number): void
export function writeFloat64(encoder: Encoder, num: number): void
export function writeBigInt64(encoder: Encoder, num: bigint): any
export function writeBigUint64(encoder: Encoder, num: bigint): any
export function writeAny(encoder: Encoder, data: AnyEncodable): void

Now come a few stateful encoder that have their own classes.

more
less

Basic Run Length Encoder - a basic compression implementation.

Encodes [1,1,1,7] to [1,3,7,1] (3 times 1, 1 time 7). This encoder might do more harm than good if there are a lot of values that are not repeated.

It was originally used for image compression. Cool .. article http://csbruce.com/cbm/transactor/pdfs/trans_v7_i06.pdf

@note — T must not be null!

@template —

export class RleEncoder<T> extends Encoder {

@param —

constructor(writer: (arg0: Encoder, arg1: T) => void)

The writer

w: (arg0: Encoder, arg1: T) => void;

Current state

more
less

@type —

s: T | null;
count: number;

@param —

write(v: T): void;
}

Basic diff decoder using variable length encoding.

more
less

Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.

export class IntDiffEncoder extends Encoder {

@param —

constructor(start: number)

Current state

more
less

@type —

s: number;

@param —

write(v: number): void;
}

A combination of IntDiffEncoder and RleEncoder.

more
less

Basically first writes the IntDiffEncoder and then counts duplicate diffs using RleEncoding.

Encodes the values [1,1,1,2,3,4,5,6] as [1,1,0,2,1,5] (RLE([1,0,0,1,1,1,1,1]) ⇒ RleIntDiff[1,1,0,2,1,5])

export class RleIntDiffEncoder extends Encoder {

@param —

constructor(start: number)

Current state

more
less

@type —

s: number;
count: number;

@param —

write(v: number): void;
}

Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.

more
less

Internally uses VarInt encoder to write unsigned integers. If the input occurs multiple times, we write write it as a negative number. The UintOptRleDecoder then understands that it needs to read a count.

Encodes [1,2,3,3,3] as [1,2,-3,3] (once 1, once 2, three times 3)

export class UintOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}
Referenced by

Increasing Uint Optimized RLE Encoder

more
less

The RLE encoder counts the number of same occurences of the same value. The IncUintOptRle encoder counts if the value increases. I.e. 7, 8, 9, 10 will be encoded as [-7, 4]. 1, 3, 5 will be encoded as [1, 3, 5].

export class IncUintOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}

A combination of the IntDiffEncoder and the UintOptRleEncoder.

more
less

The count approach is similar to the UintDiffOptRleEncoder, but instead of using the negative bitflag, it encodes in the LSB whether a count is to be read. Therefore this Encoder only supports 31 bit integers!

Encodes [1, 2, 3, 2] as [3, 1, 6, -1] (more specifically [(1 << 1) | 1, (3 << 0) | 0, -1])

Internally uses variable length encoding. Contrary to normal UintVar encoding, the first byte contains:

  • 1 bit that denotes whether the next value is a count (LSB)
  • 1 bit that denotes whether this value is negative (MSB - 1)
  • 1 bit that denotes whether to continue reading the variable length integer (MSB)

Therefore, only five bits remain to encode diff ranges.

Use this Encoder only when appropriate. In most cases, this is probably a bad idea.

export class IntDiffOptRleEncoder {
encoder: Encoder;

@type —

s: number;
count: number;
diff: number;

@param —

write(v: number): void;

Flush the encoded state and transform this to a Uint8Array.

more
less

Note that this should only be called once.

toUint8Array(): Uint8Array<ArrayBuffer>;
}

Optimized String Encoder.

more
less

Encoding many small strings in a simple Encoder is not very efficient. The function call to decode a string takes some time and creates references that must be eventually deleted. In practice, when decoding several million small strings, the GC will kick in more and more often to collect orphaned string objects (or maybe there is another reason?).

This string encoder solves the above problem. All strings are concatenated and written as a single string using a single encoding call.

The lengths are encoded using a UintOptRleEncoder.

export class StringEncoder {

@type —

sarr: string[];
s: string;

@param —

write(string: string): void;
toUint8Array(): Uint8Array<ArrayBuffer>;
}
export type AnyEncodableArray = AnyEncodable[]
Referenced by
export type AnyEncodable = undefined | null | number | bigint | boolean | string | {
[key: string]: AnyEncodable;
} | AnyEncodableArray | Uint8Array
Referenced by
}
module "environment" {
export function hasParam(name: string): boolean
export function getParam(name: string, defaultVal: string): string
export function getVariable(name: string): string | null
export function getConf(name: string): string | null
export function ensureConf(name: string): string
export function hasConf(name: string): boolean
export const isNode: boolean = ...
export const isBrowser: boolean = ...
export const isMac: boolean = ...
export const production: boolean = ...

Color is enabled by default if the terminal supports it.

more
less

Explicitly enable color using --color parameter Disable color using --no-color parameter or using NO_COLOR=1 environment variable. FORCE_COLOR=1 enables color and takes precedence over all.

export const supportsColor: boolean = ...
}
module "error" {
export function create(s: string): Error
export function methodUnimplemented(): never
export function unexpectedCase(): never
export function assert(property: boolean): asserts property is true
}
module "eventloop" {
export function enqueue(f: () => void): void
export function timeout(timeout: number, callback: Function): TimeoutObject
export function interval(timeout: number, callback: Function): TimeoutObject
export function animationFrame(cb: (arg0: number) => void): TimeoutObject
export function idleCallback(cb: Function): TimeoutObject
export function createDebouncer(timeout: number, triggerAfter?: number): (cb: ((...args: any) => void) | null) => void
export const Animation: {
new (timeoutId: number): {
_: number;
destroy(): void;
};
} = ...
export type TimeoutObject = {
destroy: Function;
}
Referenced by
}
module "func" {
export function callAll(fs: Function[], args: any[], i?: number): void
export function nop(): void
export function apply<T>(f: () => T): T
export function id<A>(a: A): A
export function equalityStrict<T>(a: T, b: T): boolean
export function equalityFlat<T>(a: T[] | object, b: T[] | object): boolean
export function equalityDeep(a: any, b: any): boolean
export function isOneOf<V, OPTS extends V>(value: V, options: OPTS[]): boolean
export function isString(s: any): s is string
export function isNumber(n: any): n is number
export function is<TYPE extends new (...args: any) => any>(n: any, T: TYPE): n is InstanceType<TYPE>
export function isTemplate<TYPE extends new (...args: any) => any>(T: TYPE): (n: any) => n is InstanceType<TYPE>
export const isArray: (arg: any) => arg is any[] = ...
}
module "indexeddb" {
export function rtop(request: IDBRequest): Promise<any>
export function openDB(name: string, initDB: (arg0: IDBDatabase) => any): Promise<IDBDatabase>
export function deleteDB(name: string): Promise<any>
export function createStores(db: IDBDatabase, definitions: string[] | string | IDBObjectStoreParameters | undefined[][]): void
export function transact(db: IDBDatabase, stores: string[], access?: "readwrite" | "readonly"): IDBObjectStore[]
export function count(store: IDBObjectStore, range?: IDBKeyRange): Promise<number>
export function get(store: IDBObjectStore, key: string | number | ArrayBuffer | Date | any[]): Promise<string | number | ArrayBuffer | Date | any[]>
export function del(store: IDBObjectStore, key: string | number | ArrayBuffer | Date | IDBKeyRange | any[]): Promise<any>
export function put(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key?: string | number | ArrayBuffer | Date | any[]): Promise<any>
export function add(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key: string | number | ArrayBuffer | Date | any[]): Promise<any>
export function addAutoKey(store: IDBObjectStore, item: string | number | ArrayBuffer | Date): Promise<number>
export function getAll(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>
export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>
export function queryFirst(store: IDBObjectStore, query: IDBKeyRange | null, direction: "next" | "prev" | "nextunique" | "prevunique"): Promise<any>
export function getLastKey(store: IDBObjectStore, range?: IDBKeyRange | null): Promise<any>
export function getFirstKey(store: IDBObjectStore, range?: IDBKeyRange | null): Promise<any>
export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<KeyValuePair[]>
export function iterate(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any, arg1: any) => void | boolean | Promise<void | boolean>, direction?: "next" | "prev" | "nextunique" | "prevunique"): Promise<void>
export function iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any) => void | boolean | Promise<void | boolean>, direction?: "next" | "prev" | "nextunique" | "prevunique"): Promise<void>
export function getStore(t: IDBTransaction, store: string): IDBObjectStore
export function createIDBKeyRangeBound(lower: any, upper: any, lowerOpen: boolean, upperOpen: boolean): IDBKeyRange
export function createIDBKeyRangeUpperBound(upper: any, upperOpen: boolean): IDBKeyRange
export function createIDBKeyRangeLowerBound(lower: any, lowerOpen: boolean): IDBKeyRange
export type KeyValuePair = {

key

k: any;

Value

v: any;
}
Referenced by
}
module "iterator" {
export function mapIterator<T, R>(iterator: Iterator<T>, f: (arg0: T) => R): IterableIterator<R>
export function createIterator<T>(next: () => IteratorResult<T>): IterableIterator<T>
export function iteratorFilter<T>(iterator: Iterator<T>, filter: (arg0: T) => boolean): IterableIterator<T>
export function iteratorMap<T, M>(iterator: Iterator<T>, fmap: (arg0: T) => M): IterableIterator<M | undefined>
}

JSON utility functions.

module "json" {

Transform JavaScript object to JSON.

more
less

@param —

@return —

export const stringify: {
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
} = ...

Parse JSON object.

more
less

@param —

@return —

export const parse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any = ...
}
module "lib0/list" {
export function create<N extends ListNode>(): List<N>
export function isEmpty<N extends ListNode>(queue: List<N>): boolean
export function remove<N extends ListNode>(list: List<N>, node: N): N
export function removeNode<N extends ListNode>(list: List<N>, node: N): N
export function insertBetween<N extends ListNode>(queue: List<N>, left: N | null, right: N | null, node: N): void
export function replace<N extends ListNode>(queue: List<N>, node: N, newNode: N): void
export function pushEnd<N extends ListNode>(queue: List<N>, n: N): void
export function pushFront<N extends ListNode>(queue: List<N>, n: N): void
export function popFront<N extends ListNode>(list: List<N>): N | null
export function popEnd<N extends ListNode>(list: List<N>): N | null
export function map<N extends ListNode, M>(list: List<N>, f: (arg0: N) => M): M[]
export function toArray<N extends ListNode>(list: List<N>): N[]
export function forEach<N extends ListNode>(list: List<N>, f: (arg0: N) => any): void

@template —

export class List<N extends ListNode> {

@type —

start: N | null;

@type —

end: N | null;
len: number;
toArray(): N[];

@param —

forEach(f: (arg0: N) => any): void;

@template —

more
less

@param —

@return —

map<M>(f: (arg0: N) => M): M[];
[Symbol.iterator](): Generator<N, void, unknown>;

@param —

[equalityTrait.EqualityTraitSymbol](other: List<any>): boolean;
}
Referenced by
}
module "lib0/logging.js" {
export function print(...args: string | Symbol | Object | number[]): void
export function warn(...args: string | Symbol | Object | number[]): void
export function printError(err: Error): void
export function printImg(url: string, height: number): void
export function printImgBase64(base64: string, height: number): void
export function group(...args: string | Symbol | Object | number[]): void
export function groupCollapsed(...args: string | Symbol | Object | number[]): void
export function groupEnd(): void
export function printDom(createNode: () => Node): void
export function printCanvas(canvas: HTMLCanvasElement, height: number): void
export function createVConsole(dom: Element): VConsole
export function createModuleLogger(moduleName: string): (...args: any[]) => void
export const vconsoles: Set<any> = ...
export class VConsole {

@param —

constructor(dom: Element)
dom: Element;

@type —

ccontainer: Element;
depth: number;

@param —

more
less

@param —

group(args: string | Symbol | Object | number[], collapsed?: boolean): void;

@param —

groupCollapsed(args: string | Symbol | Object | number[]): void;
groupEnd(): void;

@param —

print(args: string | Symbol | Object | number[]): void;

@param —

printError(err: Error): void;

@param —

more
less

@param —

printImg(url: string, height: number): void;

@param —

printDom(node: Node): void;
destroy(): void;
}
Referenced by
}
module "logging" {
export function print(...args: string | Symbol | Object | number | undefined[]): void
export function warn(...args: string | Symbol | Object | number[]): void
export function printError(err: Error): void
export function printImg(_url: string, _height: number): void
export function printImgBase64(base64: string, height: number): void
export function group(...args: string | Symbol | Object | number[]): void
export function groupCollapsed(...args: string | Symbol | Object | number[]): void
export function groupEnd(): void
export function printDom(_createNode: () => Node): void
export function printCanvas(canvas: HTMLCanvasElement, height: number): void
export function createVConsole(_dom: Element): void
export function createModuleLogger(moduleName: string): (...args: any[]) => void
export const BOLD: symbol = ...
export const UNBOLD: symbol = ...
export const BLUE: symbol = ...
export const GREY: symbol = ...
export const GREEN: symbol = ...
export const RED: symbol = ...
export const PURPLE: symbol = ...
export const ORANGE: symbol = ...
export const UNCOLOR: symbol = ...
}
module "map" {
export function create(): Map<any, any>
export function copy<K, V>(m: Map<K, V>): Map<K, V>
export function setIfUndefined<MAP extends Map<any, any>, CF extends MAP extends Map<any, infer V> ? () => V : unknown>(map: MAP, key: MAP extends Map<infer K, any> ? K : unknown, createT: CF): ReturnType<CF>
export function map<K, V, R>(m: Map<K, V>, f: (arg0: V, arg1: K) => R): R[]
export function any<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean
export function all<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean
export type GlobalMap<K, V> = Map<K, V>
}

Common Math expressions.

module "math" {
export function add(a: number, b: number): number
export function min(a: number, b: number): number
export function max(a: number, b: number): number
export function exp10(exp: number): number
export function isNegativeZero(n: number): boolean
export const floor: (x: number) => number = ...
export const ceil: (x: number) => number = ...
export const abs: (x: number) => number = ...
export const imul: (x: number, y: number) => number = ...
export const round: (x: number) => number = ...
export const log10: (x: number) => number = ...
export const log2: (x: number) => number = ...
export const log: (x: number) => number = ...
export const sqrt: (x: number) => number = ...
export const isNaN: (number: unknown) => boolean = ...
export const pow: (x: number, y: number) => number = ...
export const sign: (x: number) => number = ...
}
module "lib0/metric" {
export function prefix(n: number, baseMultiplier?: number): {
n: number;
prefix: string;
}
export const yotta: 1e+24 = ...
export const zetta: 1e+21 = ...
export const exa: 1000000000000000000 = ...
export const peta: 1000000000000000 = ...
export const tera: 1000000000000 = ...
export const giga: 1000000000 = ...
export const mega: 1000000 = ...
export const kilo: 1000 = ...
export const hecto: 100 = ...
export const deca: 10 = ...
export const deci: 0.1 = ...
export const centi: 0.01 = ...
export const milli: 0.001 = ...
export const micro: 0.000001 = ...
export const nano: 1e-9 = ...
export const pico: 1e-12 = ...
export const femto: 1e-15 = ...
export const atto: 1e-18 = ...
export const zepto: 1e-21 = ...
export const yocto: 1e-24 = ...
}
module "mutex" {
export function createMutex(): import("mutex").mutex
export type mutex = (cb: () => void, elseCb?: (() => void) | undefined) => any
Referenced by
}
module "number" {
export function countBits(n: number): number
export const MAX_SAFE_INTEGER: number = ...
export const MIN_SAFE_INTEGER: number = ...
export const LOWEST_INT32: number = ...
export const HIGHEST_INT32: number = ...
export const HIGHEST_UINT32: number = ...
export const isInteger: (number: unknown) => boolean = ...
export const isNaN: (number: unknown) => boolean = ...
export const parseInt: (string: string, radix?: number) => number = ...
}
module "object" {
export function create(): {
[key: string]: any;
}
export function isObject(o: any): o is {
[key: string]: any;
}
export function forEach<V_1>(obj: {
[key: string]: V_1;
}, f: (arg0: V_1, arg1: string) => any): void
export function map<R>(obj: {
[key: string]: any;
}, f: (arg0: any, arg1: string) => R): R[]
export function length(obj: {
[key: string]: any;
}): number
export function size(obj: {
[key: string]: any;
}): number
export function some<T extends {
[key: string | number | symbol]: any;
}>(obj: T, f: (v: T[keyof T], k: keyof T) => boolean): boolean
export function isEmpty(obj: Object | null | undefined): boolean
export function every<T extends {
[key: string | number | symbol]: any;
}>(obj: T, f: (v: T[keyof T], k: keyof T) => boolean): boolean
export function hasProperty(obj: any, key: string | number | symbol): boolean
export function equalFlat(a: {
[key: string]: any;
}, b: {
[key: string]: any;
}): boolean
export function deepFreeze<T extends unknown>(o: T): Readonly<T>
export function setIfUndefined<KV extends object, K extends keyof KV = keyof KV>(o: KV, key: K, createT: () => KV[K]): KV[K]

Object.assign

export const assign: {
<T extends {}, U>(target: T, source: U): T & U;
<T extends {}, U, V_1>(target: T, source1: U, source2: V_1): T & U & V_1;
<T extends {}, U, V_1, W>(target: T, source1: U, source2: V_1, source3: W): T & U & V_1 & W;
(target: object, ...sources: any[]): any;
} = ...

@param —

export const keys: {
(o: object): string[];
(o: {}): string[];
} = ...

@template —

more
less

@param —

@return —

export const values: {
<T>(o: {
[key: string]: T;
} | ArrayLike<T>): T[];
(o: {}): any[];
} = ...

Make an object immutable. This hurts performance and is usually not needed if you perform good coding practices.

export const freeze: {
<T extends Function>(f: T): T;
<T extends {
[key: string]: U | null | undefined | object;
}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
<T>(o: T): Readonly<T>;
} = ...
}
module "lib0/observable" {

Handles named events.

more
less

@experimental — This is basically a (better typed) duplicate of Observable, which will replace Observable in the next release.

@template —

export class ObservableV2<EVENTS extends {
[key in keyof EVENTS]: (...args: any[]) => void;
}> {

Some desc.

more
less

@type —

_observers: Map<string, Set<any>>;

@template —

more
less

@param —

@param —

on<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): EVENTS[NAME];

@template —

more
less

@param —

@param —

once<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;

@template —

more
less

@param —

@param —

off<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;

Emit a named event. All registered event listeners that listen to the specified name will receive the event.

more
less

@todo — This should catch exceptions

@template —

@param — The event name.

@param — The arguments that are applied to the event listener.

emit<NAME extends keyof EVENTS & string>(name: NAME, args: Parameters<EVENTS[NAME]>): void;
destroy(): void;
}

Handles named events.

more
less

@deprecated —

@template —

export class Observable<N> {

Some desc.

more
less

@type —

_observers: Map<N, any>;

@param —

more
less

@param —

on(name: N, f: Function): void;

@param —

more
less

@param —

once(name: N, f: Function): void;

@param —

more
less

@param —

off(name: N, f: Function): void;

Emit a named event. All registered event listeners that listen to the specified name will receive the event.

more
less

@todo — This should catch exceptions

@param — The event name.

@param — The arguments that are applied to the event listener.

emit(name: N, args: any[]): void;
destroy(): void;
}
Referenced by
}

Working with value pairs.

module "pair" {
export function create<L, R>(left: L, right: R): Pair<L, R>
export function createReversed<L, R>(right: R, left: L): Pair<L, R>
export function forEach<L, R>(arr: Pair<L, R>[], f: (arg0: L, arg1: R) => any): void
export function map<L, R, X>(arr: Pair<L, R>[], f: (arg0: L, arg1: R) => X): X[]

@template —

export class Pair<L, R> {

@param —

more
less

@param —

constructor(left: L, right: R)
left: L;
right: R;
}
Referenced by
}
module "prng" {
export function create(seed: number): PRNG
export function bool(gen: PRNG): boolean
export function int53(gen: PRNG, min: number, max: number): number
export function uint53(gen: PRNG, min: number, max: number): number
export function int32(gen: PRNG, min: number, max: number): number
export function uint32(gen: PRNG, min: number, max: number): number
export function int31(gen: PRNG, min: number, max: number): number
export function real53(gen: PRNG): number
export function char(gen: PRNG): string
export function letter(gen: PRNG): string
export function word(gen: PRNG, minLen?: number, maxLen?: number): string
export function utf16Rune(gen: PRNG): string
export function utf16String(gen: PRNG, maxlen?: number): string
export function oneOf<T>(gen: PRNG, array: T[]): T
export function uint8Array(gen: PRNG, len: number): Uint8Array<ArrayBuffer>
export function uint16Array(gen: PRNG, len: number): Uint16Array
export function uint32Array(gen: PRNG, len: number): Uint32Array

Description of the function

more
less

@callback —

A random type generator.

@typedef —

export const DefaultPRNG: typeof Xoroshiro128plus = ...
Unexported symbols referenced here

This is a variant of xoroshiro128plus - the fastest full-period generator passing BigCrush without systematic failures.

more
less

This implementation follows the idea of the original xoroshiro128plus implementation, but is optimized for the JavaScript runtime. I.e.

  • The operations are performed on 32bit integers (the original implementation works with 64bit values).
  • The initial 128bit state is computed based on a 32bit seed and Xorshift32.
  • This implementation returns two 32bit values based on the 64bit value that is computed by xoroshiro128plus. Caution: The last addition step works slightly different than in the original implementation - the add carry of the first 32bit addition is not carried over to the last 32bit.

Reference implementation

class Xoroshiro128plus {

@param — Unsigned 32 bit number

constructor(seed: number)
seed: number;
state: Uint32Array<ArrayBuffer>;
_fresh: boolean;

@return — Float/Double in [0,1)

next(): number;
}
Referenced by

Description of the function

export type generatorNext = () => number
Referenced by
}
module "promise" {
export function create<T>(f: (arg0: PromiseResolve<T>, arg1: (arg0: Error) => void) => any): Promise<T>
export function createEmpty(f: (arg0: () => void, arg1: (arg0: Error) => void) => void): Promise<void>
export function reject(reason?: Error): Promise<never>
export function resolve<T>(res: T | void): Promise<T | void>
export function resolveWith<T>(res: T): Promise<T>
export function until(timeout: number, check: () => boolean, intervalResolution?: number): Promise<void>
export function untilAsync(check: () => Promise<boolean> | boolean, timeout?: number, intervalResolution?: number): Promise<void>
export function wait(timeout: number): Promise<undefined>
export function isPromise(p: any): boolean

Promise.all wait for all promises in the array to resolve and return the result

more
less

@template —

@param —

@return —

export const all: {
<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
<T extends readonly unknown[] | []>(values: T): Promise<{
-readonly [P in keyof T]: Awaited<T[P]>;
}>;
} = ...
export type PromiseResolve<T> = (result?: T | PromiseLike<T> | undefined) => any
Referenced by
}
module "lib0/queue" {
export function create<N extends QueueNode>(): Queue<N>
export function isEmpty(queue: Queue<any>): boolean
export function enqueue<Q extends Queue<any>>(queue: Q, n: Q extends Queue<infer N> ? N : never): void
export function dequeue<N extends QueueNode>(queue: Queue<N>): N | null
export class QueueNode {

@type —

next: QueueNode | null;
}
Referenced by

@template —

export class QueueValue<V> extends QueueNode {

@param —

constructor(v: V)
v: V;
}

@template —

export class Queue<N extends QueueNode> {

@type —

start: N | null;

@type —

end: N | null;
}
Referenced by
}
module "lib0/random" {
export function uint32(): number
export function uint53(): number
export function oneOf<T>(arr: T[]): T
export function uuidv4(): string
export const rand: () => number = ...
}
module "set" {
export function create(): Set<any>
export function toArray<T>(set: Set<T>): T[]
export function first<T>(set: Set<T>): T | undefined
export function from<T>(entries: Iterable<T>): Set<T>
}
module "sort" {
export function _insertionSort<T>(arr: T[], lo: number, hi: number, compare: (arg0: T, arg1: T) => number): void
export function insertionSort<T>(arr: T[], compare: (arg0: T, arg1: T) => number): void
export function quicksort<T>(arr: T[], compare: (arg0: T, arg1: T) => number): void
}
module "statistics" {
export function median(arr: number[]): number
export function average(arr: number[]): number
}
module "lib0/storage" {
export function onChange(eventHandler: (arg0: {
key: string;
newValue: string;
oldValue: string;
}) => void): true | void
export function offChange(eventHandler: (arg0: {
key: string;
newValue: string;
oldValue: string;
}) => void): true | void

This is basically localStorage in browser, or a polyfill in nodejs

export const varStorage: any = ...
}

Utility module to work with strings.

module "string" {
export function trimLeft(s: string): string
export function fromCamelCase(s: string, separator: string): string
export function utf8ByteLength(str: string): number
export function _encodeUtf8Polyfill(str: string): Uint8Array<ArrayBuffer>
export function _encodeUtf8Native(str: string): Uint8Array<ArrayBuffer>
export function encodeUtf8(str: string): Uint8Array<ArrayBuffer>
export function _decodeUtf8Polyfill(buf: Uint8Array): string
export function _decodeUtf8Native(buf: Uint8Array): string
export function decodeUtf8(buf: Uint8Array): string
export function splice(str: string, index: number, remove: number, insert?: string): string
export function repeat(source: string, n: number): string
export function escapeHTML(str: string): string
export function unescapeHTML(str: string): string
export const fromCharCode: (...codes: number[]) => string = ...
export const fromCodePoint: (...codePoints: number[]) => string = ...

The largest utf16 character. Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)

export const MAX_UTF16_CHARACTER: string = ...
export const utf8TextEncoder: TextEncoder = ...
export let utf8TextDecoder: TextDecoder | null = ...
}

Utility module to work with EcmaScript Symbols.

module "symbol" {
export function isSymbol(s: any): boolean

Return fresh symbol.

export const create: SymbolConstructor = ...
}
module "lib0/traits" {
export function equals<T extends EqualityTrait>(a: NoInfer<T>, b: T): boolean
export const EqualityTraitSymbol: unique symbol = ...
export type EqualityTrait = {
[EqualityTraitSymbol]: (other: EqualityTrait) => boolean;
}
Referenced by
export function fingerprint(a: Fingerprintable): string
export const FingerprintTraitSymbol: unique symbol = ...

When implementing this trait, it is recommended to write some sort of "magic number" first to ensure that different types of objects don't have the same fingerprint.

more
less

The recommended pracice is to generate a random u32 number as your magic number. e.g. using console.log(random.uint32().toString(16))

export type Fingerprintable = {
[FingerprintTraitSymbol]: () => string;
} | AnyEncodable
Referenced by
}
module "lib0/testing" {
export function run(moduleName: string, name: string, f: (arg0: TestCase) => void | Promise<any>, i: number, numberOfTests: number): Promise<boolean>
export function describe(description: string, info?: string): void
export function info(info: string): void
export function group(description: string, f: (...args: any[]) => void): void
export function groupAsync(description: string, f: (...args: any[]) => Promise<any>): Promise<void>
export function measureTime(message: string, f: (...args: any[]) => void): number
export function measureTimeAsync(message: string, f: (...args: any[]) => Promise<any>): Promise<number>
export function compareArrays<T>(as: T[], bs: T[], m?: string): boolean
export function compareStrings(a: string, b: string, m?: string): void
export function compareObjects<K, V>(a: any, b: any, m?: string): void
export function compare<T>(a: T, b: T, message?: string | null, customCompare?: (arg0: any, arg1: T, arg2: T, arg3: string, arg4: any) => boolean): boolean
export function assert<T>(property: T, message?: string | null): asserts property is NonNullable<T>
export function promiseRejected(f: (...args: any[]) => Promise<any>): Promise<void>
export function fails(f: (...args: any[]) => void): void
export function failsAsync(f: (...args: any[]) => Promise<any>): Promise<void>
export function runTests(tests: {
[key: string]: {
[key: string]: (arg0: TestCase) => void | Promise<any>;
};
}): Promise<boolean>
export function fail(reason: string): never
export function skip(cond?: boolean): void
export { } from "environment"
export const extensive: boolean = ...
export const envSeed: number | null = ...
export class TestCase {

@param —

more
less

@param —

constructor(moduleName: string, testName: string)

@type —

moduleName: string;

@type —

testName: string;

This type can store custom information related to the TestCase

more
less

@type —

meta: Map<string, any>;
_seed: number | null;
_prng: PRNG | null;
resetSeed(): void;
get seed(): number;
get prng(): prng.PRNG;
}
Referenced by
export const repetitionTime: number = ...
export const printDom: (_createNode: () => Node) => void = ...
export const printCanvas: (canvas: HTMLCanvasElement, height: number) => void = ...
}
module "time" {
export function getDate(): Date
export function humanizeDuration(d: number): string

Return current unix time.

more
less

@return —

export const getUnixTime: () => number = ...
}
module "tree" {

This is a Red Black Tree implementation

more
less

@template —

export class Tree<K, V> {
root: any;
length: number;

@param —

findNext(id: K): V;

@param —

findPrev(id: K): V;

@param —

findNodeWithLowerBound(from: K): any;

@param —

findNodeWithUpperBound(to: K): any;

@return —

findSmallestNode(): V;

@param —

more
less

@return —

findWithLowerBound(from: K): V;

@param —

more
less

@return —

findWithUpperBound(to: K): V;

@param —

more
less

@param —

@param —

iterate(from: K, to: any, f: (arg0: V) => void): void;

@param —

more
less

@return —

find(id: K): V | null;

@param —

more
less

@return —

findNode(id: K): N<V> | null;

@param —

delete(id: K): void;
_fixDelete(n: any): void;
put(v: any): any;
_fixInsert(n: any): void;
}
Unexported symbols referenced here

@template —

class N<V> {

A created node is always red!

more
less

@param —

constructor(val: V)
val: V;
color: boolean;
_left: any;
_right: any;
_parent: any;
isRed(): boolean;
isBlack(): boolean;
redden(): this;
blacken(): this;
get grandparent(): any;
get parent(): any;
get sibling(): any;
set left(n: any);
get left(): any;
set right(n: any);
get right(): any;
rotateLeft(tree: any): void;
next(): any;
prev(): any;
rotateRight(tree: any): void;
getUncle(): any;
}
Referenced by
}
module "lib0/url" {
export function decodeQueryParams(url: string): {
[key: string]: string;
}
export function encodeQueryParams(params: {
[key: string]: string;
}): string
}
module "websocket" {

@deprecated —

more
less

@extends —

export class WebsocketClient extends Observable<string> {

@param —

more
less

@param —

constructor(url: string, { binaryType }?: {
binaryType?: "arraybuffer" | "blob" | null | undefined;
})
url: string;

@type —

ws: WebSocket | null;
binaryType: "arraybuffer" | "blob" | null;
connected: boolean;
connecting: boolean;
unsuccessfulReconnects: number;
lastMessageReceived: number;

Whether to connect to other peers or not

more
less

@type —

shouldConnect: boolean;
_checkInterval: Timeout;

@param —

send(message: any): void;
disconnect(): void;
connect(): void;
}
}
module "lib0/webcrypto" {
export const subtle: SubtleCrypto = ...
export const getRandomValues: <T extends ArrayBufferView>(array: T) => T = ...
}
module "lib0/performance" {
export const measure: (measureName: string, startOrMeasureOptions?: string | PerformanceMeasureOptions, endMark?: string) => PerformanceMeasure = ...
export const now: () => DOMHighResTimeStamp = ...
export const mark: (markName: string, markOptions?: PerformanceMarkOptions) => PerformanceMark = ...
}
module "lib0/schema" {
export function $constructedBy<C extends (new (...args: any[]) => any) | ((...args: any[]) => any)>(c: C, check?: ((o: Instance<C>) => boolean) | null): CastToSchema<$ConstructedBy<C>>
export function $custom(check: (o: any) => boolean): Schema<any>
export function $literal<T extends Primitive[]>(...literals: T): CastToSchema<$Literal<T[number]>>
export function $stringTemplate<T extends string | Schema<string | number>[]>(...literals: T): CastToSchema<$StringTemplate<T>>
export function $object<S extends {
[key: string | symbol | number]: Schema<any>;
}>(def: S): _ObjectDefToSchema<S> extends Schema<infer S_1> ? Schema<{
[K in keyof S_1]: S_1[K];
}> : never
export function $record<Keys extends Schema<string | number | symbol>, Values extends Schema<any>>(keys: Keys, values: Values): CastToSchema<$Record<Keys, Values>>
export function $tuple<T extends Schema<any>[]>(...def: T): CastToSchema<$Tuple<T>>
export function $array<T extends Schema<any>[]>(...def: T): Schema<T extends Schema<infer S>[] ? S : never[]>
export function $instanceOf<T>(c: new (...args: any) => T, check?: ((o: T) => boolean) | null): Schema<T>
export function $lambda<Args extends Schema<any>[]>(...args: Args): Schema<(...args: UnwrapArray<TuplePop<Args>>) => Unwrap<TupleLast<Args>>>
export function $intersect<T extends Schema<any>[]>(...def: T): CastToSchema<$Intersection<T>>
export function $union<T extends any[]>(...schemas: T): CastToSchema<$Union<Unwrap<ReadSchema<T>>>>
export function $<IN>(o: IN): ReadSchema<IN>
export function match<State = undefined>(state?: State): PatternMatcher<State extends undefined ? undefined : Unwrap<ReadSchema<State>>>
export function random<S>(gen: PRNG, schema: S): Unwrap<ReadSchema<S>>
export class ValidationError {

Reverse errors

more
less

@type —

_rerrs: {
path: string | null;
expected: string;
has: string;
message: string | null;
}[];

@param —

more
less

@param —

@param —

@param —

extend(path: string | null, expected: string, has: string, message?: string | null): void;
toString(): string;
}
Referenced by

@template —

more
less

@implements —

export class Schema<T> implements EqualityTrait {

If true, the more things are added to the shape the more objects this schema will accept (e.g. union). By default, the more objects are added, the the fewer objects this schema will accept.

more
less

@protected —

static _dilutes: boolean;

@param —

extends(other: Schema<any>): boolean;

Overwrite this when necessary. By default, we only check the shape property which every shape should have.

more
less

@param —

equals(other: Schema<any>): boolean;

Use schema.validate(obj) with a typed parameter that is already of typed to be an instance of Schema. Validate will check the structure of the parameter and return true iff the instance really is an instance of Schema.

more
less

@param —

@return —

validate(o: T): boolean;

Similar to validate, but this method accepts untyped parameters.

more
less

@param —

@param —

@return —

check(_o: any, _err?: ValidationError): _o is T;
get nullable(): Schema<T | null>;
get optional(): $Optional<Schema<T>>;

Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise. Use this if you know that the type is of a specific type and you just want to convince the type system.

more
less

Do not rely on these error messages! Performs an assertion check only if not in a production environment.

@template —

@param —

@return —

cast<OO>(o: OO): Extract<OO, T> extends never ? T : (OO extends never[] ? T : Extract<OO, T>);

EXPECTO PATRONUM!! 🪄 This function protects against type errors. Though it may not work in the real world.

more
less

"After all this time?" "Always." - Snape, talking about type safety

Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed. Use this if you know that the type is of a specific type and you just want to convince the type system.

Can be useful when defining lambdas: s.lambda(s.$number, s.$void).expect((n) => n + 1)

Do not rely on these error messages! Performs an assertion check if not in a production environment.

@param —

@return —

expect(o: T): T extends T ? T : never;
[schemaSymbol](): boolean;

@param —

[equalityTraits.EqualityTraitSymbol](other: object): boolean;
}
Referenced by

@template —

more
less

@typedef —

@template —

@extends —

export class $ConstructedBy<C extends (new (...args: any[]) => any) | ((...args: any[]) => any)> extends Schema<Instance<C>> {

@param —

more
less

@param —

constructor(c: C, check: ((o: Instance<C>) => boolean) | null)
shape: C;
_c: ((o: Instance<C>) => boolean) | null;

@param —

more
less

@param —

@return — o

check(o: any, err?: ValidationError): o is C extends ((...args: any[]) => infer T) ? T : (C extends (new (...args: any[]) => any) ? InstanceType<C> : never);
}
Referenced by
export const $$constructedBy: Schema<$ConstructedBy<(new (...args: any[]) => any) | ((...args: any[]) => any)>> = ...

Check custom properties on any object. You may want to overwrite the generated Schema.

more
less

@extends —

export class $Custom extends Schema<any> {

@param —

constructor(check: (o: any) => boolean)

@type —

shape: (o: any) => boolean;

@param —

more
less

@param —

@return —

check(o: any, err: ValidationError): o is any;
}
Referenced by
export const $$custom: Schema<$Custom> = ...

@template —

more
less

@extends —

export class $Literal<T extends Primitive> extends Schema<T> {

@param —

constructor(literals: T[])
shape: T[];
}
Referenced by
export const $$literal: Schema<$Literal<Primitive>> = ...

@template —

more
less

@extends —

export class $StringTemplate<T extends string | Schema<string | number>[]> extends Schema<CastStringTemplateArgsToTemplate<T>> {

@param —

constructor(shape: T)
shape: T;
_r: RegExp;
}
Referenced by
export const $$stringTemplate: Schema<$StringTemplate<(string | Schema<string | number>)[]>> = ...
export const $$optional: Schema<$Optional<Schema<any>>> = ...
Unexported symbols referenced here

@template —

more
less

@extends —

class $Optional<S extends Schema<any>> extends Schema<Unwrap<S> | undefined> {

@param —

constructor(shape: S)
shape: S;
get [isOptionalSymbol](): boolean;
}
Referenced by

@type —

export const $never: Schema<never> = ...
export const $$never: Schema<$Never> = ...
Unexported symbols referenced here

@extends —

class $Never extends Schema<never> {
constructor()
}
Referenced by

@template —

more
less

@typedef —

@template —

@extends —

export class $Object<S extends {
[key: string | symbol | number]: Schema<any>;
}> extends Schema<$ObjectToType<S>> {

@param —

more
less

@param —

constructor(shape: S, partial?: boolean)

@type —

shape: S;
_isPartial: boolean;
get partial(): Schema<Partial<$ObjectToType<S>>>;

@param —

more
less

@param —

@return —

check(o: any, err: ValidationError): o is $ObjectToType<S>;
}
Referenced by
export const $$object: Schema<$Object<{
[key: string]: Schema<any>;
[key: number]: Schema<any>;
[key: symbol]: Schema<any>;
}>> = ...

@type —

export const $objectAny: Schema<{
[key: string]: any;
}> = ...

@template —

more
less

@template —

@extends —

export class $Record<Keys extends Schema<string | number | symbol>, Values extends Schema<any>> extends Schema<{
[key in Unwrap<Keys>]: Unwrap<Values>;
}> {

@param —

more
less

@param —

constructor(keys: Keys, values: Values)
shape: {
keys: Keys;
values: Values;
};

@param —

more
less

@param —

@return —

check(o: any, err: ValidationError): o is {
[key_1 in Unwrap<Keys>]: Unwrap<Values>;
};
}
Referenced by
export const $$record: Schema<$Record<Schema<string | number | symbol>, Schema<any>>> = ...

@template —

more
less

@extends —

export class $Tuple<S extends Schema<any>[]> extends Schema<{
[Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never;
}> {

@param —

constructor(shape: S)
shape: S;

@param —

more
less

@param —

@return —

check(o: any, err: ValidationError): o is {
[K in keyof S]: S[K] extends Schema<infer Type> ? Type : never;
};
}
Referenced by
export const $$tuple: Schema<$Tuple<Schema<any>[]>> = ...

@template —

more
less

@extends —

export class $Array<S extends Schema<any>> extends Schema<(S extends Schema<infer T> ? T : never)[]> {

@param —

constructor(v: S[])

@type —

shape: Schema<S extends Schema<infer T_1> ? T_1 : never>;

@param —

more
less

@param —

@return — o

check(o: any, err?: ValidationError): o is S extends Schema<infer T_1> ? T_1 : never[];
}
Referenced by
export const $$array: Schema<$Array<Schema<any>>> = ...

@type —

export const $arrayAny: Schema<any[]> = ...

@template —

more
less

@extends —

export class $InstanceOf<T> extends Schema<T> {

@param —

more
less

@param —

constructor(constructor: new (...args: any) => T, check: ((o: T) => boolean) | null)
shape: new (...args: any) => T;
_c: ((o: T) => boolean) | null;

@param —

more
less

@param —

@return —

check(o: any, err: ValidationError): o is T;
}
Referenced by
export const $$instanceOf: Schema<$InstanceOf<unknown>> = ...
export const $$schema: Schema<Schema<unknown>> = ...

@template —

more
less

@typedef —

@template —

@extends —

export class $Lambda<Args extends Schema<any>[]> extends Schema<_LArgsToLambdaDef<Args>> {

@param —

constructor(args: Args)
len: number;
args: Schema<any[]>;
res: Schema<any>;

@param —

more
less

@param —

@return —

check(f: any, err: ValidationError): f is _LArgsToLambdaDef<Args>;
}
Referenced by
export const $$lambda: Schema<$Lambda<Schema<any>[]>> = ...

@type —

export const $function: Schema<Function> = ...

@template —

more
less

@extends —

export class $Intersection<T extends Schema<any>[]> extends Schema<Intersect<UnwrapArray<T>>> {

@param —

constructor(v: T)

@type —

shape: T;
}
Referenced by
export const $$intersect: Schema<$Intersection<Schema<any>[]>> = ...

@template —

more
less

@extends —

export class $Union<S> extends Schema<S> {

@param —

constructor(v: Schema<S>[])
shape: Schema<S>[];
}
Referenced by
export const $$union: Schema<$Union<any>> = ...

@type —

export const $any: Schema<any> = ...
export const $$any: Schema<Schema<any>> = ...

@type —

export const $bigint: Schema<bigint> = ...
export const $$bigint: Schema<Schema<bigint>> = ...

@type —

export const $symbol: Schema<symbol> = ...
export const $$symbol: Schema<Schema<Symbol>> = ...

@type —

export const $number: Schema<number> = ...
export const $$number: Schema<Schema<number>> = ...

@type —

export const $string: Schema<string> = ...
export const $$string: Schema<Schema<string>> = ...

@type —

export const $boolean: Schema<boolean> = ...
export const $$boolean: Schema<Schema<boolean>> = ...

@type —

export const $undefined: Schema<undefined> = ...
export const $$undefined: Schema<Schema<undefined>> = ...

@type —

export const $void: Schema<void> = ...
export const $$void: Schema<Schema<void>> = ...
export const $null: Schema<null> = ...
export const $$null: Schema<Schema<null>> = ...
export const $uint8Array: Schema<Uint8Array<ArrayBuffer>> = ...
export const $$uint8Array: Schema<Schema<Uint8Array>> = ...

@type —

export const $primitive: Schema<Primitive> = ...

@typedef —

more
less

@typedef —

@type —

export const $json: Schema<null | number | string | boolean | JSON[] | {
[key: string]: JSON;
}> = ...

Assert that a variable is of this specific type. The assertion check is only performed in non-production environments.

more
less

@type —

export const assert: <T>(o: any, schema: Schema<T>) => asserts o is T = ...

@template —

more
less

@template —

@typedef —

@template —

@template —

@typedef —

@todo — move this to separate library

@template —

@template —

export class PatternMatcher<State extends unknown = undefined, Patterns extends Pattern<any, any> = never> {

@param —

constructor($state?: Schema<State>)

@type —

patterns: Patterns[];
$state: Schema<State> | undefined;

@template —

more
less

@template —

@param —

@param —

@return —

if<P, R>(pattern: P, handler: (o: NoInfer<Unwrap<ReadSchema<P>>>, s: State) => R): PatternMatcher<State, Patterns | Pattern<Unwrap<ReadSchema<P>>, R>>;

@template —

more
less

@param —

else<R>(h: (o: any, s: State) => R): PatternMatcher<State, Patterns | Pattern<any, R>>;

@return —

done(): State extends undefined ? <In extends Unwrap<Patterns["if"]>>(o: In, state?: undefined) => PatternMatchResult<Patterns, In> : <In extends Unwrap<Patterns["if"]>>(o: In, state: State) => PatternMatchResult<Patterns, In>;
}
Referenced by
export type Primitive = string | number | bigint | boolean | null | undefined | symbol
Referenced by
export type AnyObject = {
[key: string | number | symbol]: any;
}
export type TypeOf<T> = T extends Schema<infer X> ? X : T
export type UnwrapArray<T extends readonly unknown[]> = T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : []
Referenced by
export type CastToSchema<T> = T extends Schema<infer S> ? Schema<S> : never
Referenced by
export type TupleLast<Arr extends unknown[]> = Arr extends [...unknown[], infer L] ? L : never
Referenced by
export type TuplePop<Arr extends unknown[]> = Arr extends [...infer Fs, unknown] ? Fs : never
Referenced by
export type Intersect<T extends readonly unknown[]> = T extends [] ? {} : T extends [infer First] ? First : T extends [infer First, ...infer Rest] ? First & Intersect<Rest> : never
Referenced by
export type Instance<Constr extends (new (...args: any[]) => any) | ((...args: any[]) => any)> = Constr extends ((...args: any[]) => infer T) ? T : (Constr extends (new (...args: any[]) => any) ? InstanceType<Constr> : never)
Referenced by
export type CastStringTemplateArgsToTemplate<Ts extends string | Schema<string | number>[]> = Ts extends [] ? `` LiteralType : (Ts extends [infer T] ? (Unwrap<T> extends (string | number) ? Unwrap<T> : never) : (Ts extends [infer T1, ...infer Rest] ? `${Unwrap<T1> extends (string | number) ? Unwrap<T1> : never}${Rest extends string | Schema<string | number>[] ? CastStringTemplateArgsToTemplate<Rest> : never}` : never))
Referenced by
export type $ObjectToType<S extends {
[key: string | symbol | number]: Schema<any>;
}> = {
[Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never;
} & {
[Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never;
}
Referenced by
export type _ObjectDefToSchema<S> = Schema<{
[Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never;
} & {
[Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never;
}>
Referenced by
export type _LArgsToLambdaDef<Args extends Schema<any>[]> = (...args: UnwrapArray<TuplePop<Args>>) => Unwrap<TupleLast<Args>>
Referenced by
export type JSONArray = JSON[]
Referenced by
export type JSON = Primitive | JSONArray | {
[key: string]: JSON;
}
Referenced by
export type ReadSchemaOld<IN extends unknown> = IN extends Schema<any> ? IN : (IN extends string | number | boolean | null ? Schema<IN> : (IN extends new (...args: any[]) => any ? Schema<InstanceType<IN>> : (IN extends any[] ? Schema<{
[K in keyof IN]: Unwrap<ReadSchema<IN[K]>>;
}[number]> : (IN extends object ? (_ObjectDefToSchema<{
[K in keyof IN]: ReadSchema<IN[K]>;
}> extends Schema<infer S> ? Schema<{
[K in keyof S]: S[K];
}> : never) : never))))
export type ReadSchema<IN extends unknown> = [Extract<IN, Schema<any>>, Extract<IN, string | number | boolean | null>, Extract<IN, new (...args: any[]) => any>, Extract<IN, any[]>, Extract<Exclude<IN, Schema<any> | string | number | boolean | null | (new (...args: any[]) => any) | any[]>, object>] extends [infer Schemas, infer Primitives, infer Constructors, infer Arrs, infer Obj] ? Schema<(Schemas extends Schema<infer S> ? S : never) | Primitives | (Constructors extends new (...args: any[]) => any ? InstanceType<Constructors> : never) | (Arrs extends any[] ? {
[K in keyof Arrs]: Unwrap<ReadSchema<Arrs[K]>>;
}[number] : never) | (Obj extends object ? Unwrap<(_ObjectDefToSchema<{
[K in keyof Obj]: ReadSchema<Obj[K]>;
}> extends Schema<infer S> ? Schema<{
[K in keyof S]: S[K];
}> : never)> : never)> : never
Referenced by
export type Q = ReadSchema<{
x: 42;
} | {
y: 99;
} | Schema<string> | [1, 2, {}]>
export type Pattern<In, Out> = {
if: Schema<In>;
h: (o: In, state?: any) => Out;
}
Referenced by
export type PatternMatchResult<P extends Pattern<any, any>, In> = ReturnType<Extract<P, Pattern<In extends number ? number : (In extends string ? string : In), any>>["h"]>
Referenced by
}