Transforms something array-like to an actual Array.
@function —
@template —
@param —
@return —
Binary data constants.
@param —
@return —
A Decoder handles the decoding of an Uint8Array.
@template —
@param — Binary data to decode
constructor(uint8Array: Uint8Array<Buf>)Decoding target.
@type —
Current decoding position.
@type —
T must not be null.
@template —
Current state
@type —
@param —
@param —
Current state
@type —
@return —
read(): number;@param —
@param —
Current state
@type —
@return —
read(): number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@return —
read(): number;@param —
constructor(uint8Array: Uint8Array)@type —
spos: number;@return —
read(): string;A SimpleDiff describes a change on a String.
console.log(a) // the old valueconsole.log(b) // the updated value// Apply changes of diff (pseudocode)a.remove(diff.index, diff.remove) // Remove `diff.remove` charactersa.insert(diff.index, diff.insert) // Insert `diff.insert`a === b // values match
The index where changes were applied
index: number;The number of characters to delete starting
at index.
The new text to insert at index after applying
A BinaryEncoder handles the encoding to an Uint8Array.
export class Encoder {@type —
bufs: Uint8Array[];Now come a few stateful encoder that have their own classes.
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 —
Current state
@type —
@param —
write(v: T): void;Basic diff decoder using variable length encoding.
Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.
@param —
constructor(start: number)Current state
@type —
@param —
write(v: number): void;A combination of IntDiffEncoder and RleEncoder.
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])
@param —
constructor(start: number)Current state
@type —
@param —
write(v: number): void;Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.
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)
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
Increasing Uint Optimized RLE Encoder
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].
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
A combination of the IntDiffEncoder and the UintOptRleEncoder.
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:
Therefore, only five bits remain to encode diff ranges.
Use this Encoder only when appropriate. In most cases, this is probably a bad idea.
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
Optimized String Encoder.
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.
@type —
sarr: string[];@param —
write(string: string): void;Color is enabled by default if the terminal supports it.
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.
JSON utility functions.
Transform JavaScript object to JSON.
@param —
@return —
Common Math expressions.
Object.assign
export const assign: {@template —
@param —
@return —
Make an object immutable. This hurts performance and is usually not needed if you perform good coding practices.
export const freeze: {Working with value pairs.
@template —
export class Pair<L, R> {@param —
@param —
Description of the function
@callback —
A random type generator.
@typedef —
This is a variant of xoroshiro128plus - the fastest full-period generator passing BigCrush without systematic failures.
This implementation follows the idea of the original xoroshiro128plus implementation, but is optimized for the JavaScript runtime. I.e.
@param — Unsigned 32 bit number
constructor(seed: number)@return — Float/Double in [0,1)
next(): number;Description of the function
export type generatorNext = () => numberPromise.all wait for all promises in the array to resolve and return the result
@template —
@param —
@return —
Utility module to work with strings.
The largest utf16 character. Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)
export const MAX_UTF16_CHARACTER: string = ...Return current unix time.
@return —
This is a Red Black Tree implementation
@template —
@param —
findNext(id: K): V;@param —
findPrev(id: K): V;@param —
findNodeWithLowerBound(from: K): any;@param —
findNodeWithUpperBound(to: K): any;@return —
findSmallestNode(): V;@param —
@return —
@param —
@return —
@param —
@param —
@param —
@param —
@return —
@param —
delete(id: K): void;@template —
class N<V> {A created node is always red!
@param —
@deprecated —
@extends —
@param —
@param —
@type —
ws: WebSocket | null;Whether to connect to other peers or not
@type —
@param —
send(message: any): void;Transforms something array-like to an actual Array.
@function —
@template —
@param —
@return —
Binary data constants.
@param —
@return —
@template —
export class Lib0Component<S> extends HTMLElement {@param —
constructor(state?: S)@type —
state: S | null;@type —
_internal: any;@param —
@param — Force that the state is rerendered even if state didn't change
@param —
updateState(_stateUpdate: any): void;Template for the shadow dom.
template?: string | null | undefined;shadow dom style. Is only used when
CONF.template is defined
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?: {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
Maps from dom-event-name to event listener.
listeners?: { } | undefined;Fill slots automatically when state changes. Maps from slot-name to slot-html.
slots?: ((arg0: S, arg1: S, arg2: Lib0Component<S>) => {@template —
@overload —
@template —
@template —
@overload —
@template —
@overload —
@template —
@template —
@template —
@overload —
@typedef —
@typedef —
@typedef —
@typedef —
@typedef —
@typedef —
@typedef —
@typedef —
@type —
@param —
@param —
@param —
@readonly —
@type —
@type —
_fingerprint: string | null;@param —
_updateInsert(newVal: string): void;Remove a part of the operation (similar to Array.splice)
@param —
@param —
@template —
export class InsertOp<ArrayContent extends Fingerprintable> extends ListNode {@param —
@param —
@param —
@readonly —
@type —
@type —
_fingerprint: string | null;@param —
_updateInsert(newVal: ArrayContent): void;Remove a part of the operation (similar to Array.splice)
@param —
@param —
@template —
@template —
@param —
constructor(len: number)@type —
prevValue: (Children | Text) extends never ? null : (Delta<any, {}, Children, Text> | null);@type —
_fingerprint: string | null;Remove a part of the operation (similar to Array.splice)
@param —
@param —
@param —
@param —
@param —
@readonly —
@type —
@type —
_fingerprint: string | null;Remove a part of the operation (similar to Array.splice)
@param —
@param —
Delta that can be applied on a YType Embed
@template —
@param —
@param —
@param —
@readonly —
@type —
@type —
_fingerprint: string | null;Remove a part of the operation (similar to Array.splice)
@param —
@param —
@template —
@template —
@param —
@param —
@param —
@param —
@readonly —
@type —
@readonly —
@type —
@readonly —
@type —
@type —
_fingerprint: string | null;@template —
@template —
@param —
@param —
@param —
@type —
key: K;@type —
prevValue: V | undefined;@type —
_fingerprint: string | null;@template —
@template —
@param —
@param —
@readonly —
@type —
@readonly —
@type —
@type —
_fingerprint: string | null;@template —
@template —
@typedef —
@template —
@template —
@template —
@typedef —
@template —
@template —
@typedef —
@template —
@typedef —
@template —
@typedef —
@typedef —
@typedef —
@template —
@template —
@template —
@template —
@template —
@param —
@param —
@type —
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)>;@type —
origin: any;@type —
_fingerprint: string | null;@param —
@param —
@return —
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.
@return —
@param —
@return —
@template —
@template —
@template —
@template —
@template —
@extends —
@param —
@param —
@template —
@param —
@param —
@template —
@param —
@param —
@param —
@return —
@template —
@param —
@param —
@param —
@return —
@param —
@param —
@param —
@param —
delete(len: number): this;@template —
@template —
@param —
@param —
@param —
@param —
@return —
@template —
@param —
@param —
@return —
@template —
@param —
@param —
@param —
@return —
@template —
@template —
@param —
@param —
@return —
Same as doing delta.rebase(other.inverse()), without creating a temporary delta.
@param —
@param —
Append child ops from one op to the other.
delta.create().insert('a').append(delta.create().insert('b')) // => insert "ab"
@template —
@param —
@return —
@template —
@typedef —
@template —
@template —
@template —
@template —
@typedef —
@template —
@template —
@template —
@template —
@template —
@template —
@extends —
@param —
@param —
@param —
@param —
@param —
@param —
@param — assert(m[0] === 1)
constructor(m: Uint8Array)This describes the position of the most significant byte (starts with 0 and increases with shift)
bpos: number;@param —
write(byte: number): void;A Decoder handles the decoding of an Uint8Array.
@template —
@param — Binary data to decode
constructor(uint8Array: Uint8Array<Buf>)Decoding target.
@type —
Current decoding position.
@type —
T must not be null.
@template —
Current state
@type —
@param —
@param —
Current state
@type —
@return —
read(): number;@param —
@param —
Current state
@type —
@return —
read(): number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@param —
constructor(uint8Array: Uint8Array)@type —
s: number;@return —
read(): number;@param —
constructor(uint8Array: Uint8Array)@type —
spos: number;@return —
read(): string;A SimpleDiff describes a change on a String.
console.log(a) // the old valueconsole.log(b) // the updated value// Apply changes of diff (pseudocode)a.remove(diff.index, diff.remove) // Remove `diff.remove` charactersa.insert(diff.index, diff.insert) // Insert `diff.insert`a === b // values match
The index where changes were applied
index: number;The number of characters to delete starting
at index.
The new text to insert at index after applying
A BinaryEncoder handles the encoding to an Uint8Array.
export class Encoder {@type —
bufs: Uint8Array[];Now come a few stateful encoder that have their own classes.
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 —
Current state
@type —
@param —
write(v: T): void;Basic diff decoder using variable length encoding.
Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.
@param —
constructor(start: number)Current state
@type —
@param —
write(v: number): void;A combination of IntDiffEncoder and RleEncoder.
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])
@param —
constructor(start: number)Current state
@type —
@param —
write(v: number): void;Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.
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)
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
Increasing Uint Optimized RLE Encoder
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].
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
A combination of the IntDiffEncoder and the UintOptRleEncoder.
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:
Therefore, only five bits remain to encode diff ranges.
Use this Encoder only when appropriate. In most cases, this is probably a bad idea.
@type —
s: number;@param —
write(v: number): void;Flush the encoded state and transform this to a Uint8Array.
Note that this should only be called once.
Optimized String Encoder.
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.
@type —
sarr: string[];@param —
write(string: string): void;Color is enabled by default if the terminal supports it.
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.
JSON utility functions.
Transform JavaScript object to JSON.
@param —
@return —
@type —
next: this | null;@type —
prev: this | null;@template —
export class List<N extends ListNode> {@type —
start: N | null;@type —
end: N | null;@param —
forEach(f: (arg0: N) => any): void;@template —
@param —
@return —
@param —
constructor(dom: Element)@type —
ccontainer: Element;@param —
@param —
@param —
groupCollapsed(args: string | Symbol | Object | number[]): void;@param —
print(args: string | Symbol | Object | number[]): void;@param —
printError(err: Error): void;@param —
@param —
@param —
printDom(node: Node): void;Common Math expressions.
Object.assign
export const assign: {@template —
@param —
@return —
Make an object immutable. This hurts performance and is usually not needed if you perform good coding practices.
export const freeze: {Handles named events.
@experimental — This is basically a (better typed) duplicate of Observable, which will replace Observable in the next release.
@template —
Some desc.
@type —
@template —
@param —
@param —
@template —
@param —
@param —
@template —
@param —
@param —
Emit a named event. All registered event listeners that listen to the specified name will receive the event.
@todo — This should catch exceptions
@template —
@param — The event name.
@param — The arguments that are applied to the event listener.
Handles named events.
@deprecated —
@template —
Some desc.
@type —
@param —
@param —
@param —
@param —
@param —
@param —
Emit a named event. All registered event listeners that listen to the specified name will receive the event.
@todo — This should catch exceptions
@param — The event name.
@param — The arguments that are applied to the event listener.
Working with value pairs.
@template —
export class Pair<L, R> {@param —
@param —
Description of the function
@callback —
A random type generator.
@typedef —
This is a variant of xoroshiro128plus - the fastest full-period generator passing BigCrush without systematic failures.
This implementation follows the idea of the original xoroshiro128plus implementation, but is optimized for the JavaScript runtime. I.e.
@param — Unsigned 32 bit number
constructor(seed: number)@return — Float/Double in [0,1)
next(): number;Description of the function
export type generatorNext = () => numberPromise.all wait for all promises in the array to resolve and return the result
@template —
@param —
@return —
This is basically localStorage in browser, or a polyfill in nodejs
export const varStorage: any = ...Utility module to work with strings.
The largest utf16 character. Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)
export const MAX_UTF16_CHARACTER: string = ...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.
The recommended pracice is to generate a random u32 number as your magic number. e.g. using
console.log(random.uint32().toString(16))
@param —
@param —
@type —
moduleName: string;@type —
testName: string;This type can store custom information related to the TestCase
@type —
Return current unix time.
@return —
This is a Red Black Tree implementation
@template —
@param —
findNext(id: K): V;@param —
findPrev(id: K): V;@param —
findNodeWithLowerBound(from: K): any;@param —
findNodeWithUpperBound(to: K): any;@return —
findSmallestNode(): V;@param —
@return —
@param —
@return —
@param —
@param —
@param —
@param —
@return —
@param —
delete(id: K): void;@template —
class N<V> {A created node is always red!
@param —
@deprecated —
@extends —
@param —
@param —
@type —
ws: WebSocket | null;Whether to connect to other peers or not
@type —
@param —
send(message: any): void;Reverse errors
@type —
@param —
@param —
@param —
@param —
@template —
@implements —
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.
@protected —
Overwrite this when necessary. By default, we only check the shape property which every shape
should have.
@param —
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.
@param —
@return —
Similar to validate, but this method accepts untyped parameters.
@param —
@param —
@return —
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.
Do not rely on these error messages! Performs an assertion check only if not in a production environment.
@template —
@param —
@return —
EXPECTO PATRONUM!! 🪄 This function protects against type errors. Though it may not work in the real world.
"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 —
@param —
[equalityTraits.EqualityTraitSymbol](other: object): boolean;@template —
@typedef —
@template —
@extends —
@param —
@param —
@return — o
Check custom properties on any object. You may want to overwrite the generated Schema.
@extends —
@param —
constructor(check: (o: any) => boolean)@type —
shape: (o: any) => boolean;@template —
@extends —
@param —
constructor(shape: T)@template —
@typedef —
@template —
@extends —
@param —
@param —
@type —
shape: S;@param —
@param —
@return —
@template —
@template —
@extends —
@param —
@param —
@template —
@extends —
@param —
constructor(shape: S)@template —
@extends —
@param —
constructor(v: S[])@param —
@param —
@return — o
@template —
@extends —
@param —
@param —
@template —
@typedef —
@template —
@extends —
@param —
constructor(args: Args)@param —
@param —
@return —
@template —
@extends —
@param —
constructor(v: T)@type —
shape: T;Assert that a variable is of this specific type. The assertion check is only performed in non-production environments.
@type —
@template —
@template —
@typedef —
@template —
@template —
@typedef —
@todo — move this to separate library
@template —
@template —
@type —
patterns: Patterns[];@template —
@template —
@param —
@param —
@return —
@template —
@param —
@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>;