import Coder from "../Coder.js"; import Memory from "../Memory.js"; import { Augmented } from "../augment.js"; import DataBuffer from "../DataBuffer.js"; import { DispatcherWithMemory } from "../schemaOf.js"; export type Dispatcher = (value: Type) => void; export type DispatcherRecord = Record>; export type PropertiesDispatcher = { [K in keyof O]: Dispatcher; }; /** * The Encoder abstract class implements the encoding logic without the details. */ export default abstract class Encoder implements Coder { capacity: number; buffer: DataBuffer; size: number; memory: Memory>; abstract onCapacityFull(demandedSize: number): void; constructor(capacity?: number, buffer?: DataBuffer); get data(): Uint8Array; byte(value: number): void; bytes(value: Uint8Array): void; incrementSizeBy(value: number): void; reset(): void; encode(value: any, schema?: Dispatcher | DispatcherWithMemory): any; inMemory(object: object): boolean; /** * --- Primitives */ unknown(): void; character(value: number): void; binary(value: Uint8Array): void; uint8Array(value: Uint8Array): void; uint16Array(value: Uint16Array): void; uint32Array(value: Uint32Array): void; uint8ClampedArray(value: Uint8ClampedArray): void; int8Array(value: Int8Array): void; int16Array(value: Int16Array): void; int32Array(value: Int32Array): void; float32Array(value: Float32Array): void; float64Array(value: Float64Array): void; bigInt64Array(value: BigInt64Array): void; bigUint64Array(value: BigUint64Array): void; arrayBuffer(value: ArrayBuffer): void; dataView(value: DataView): void; boolean(value: boolean): void; positiveInteger(value: number): void; integer(value: number): void; bigInteger(value: bigint): void; number(value: number): void; string(value: string): void; regularExpression(value: RegExp): void; date(value: Date): void; any(value: any): void; /** * --- Constructibles */ nullable(dispatch?: Dispatcher): Augmented<(this: Encoder, value: T | null | undefined) => void>; tuple(dispatchers: { [Index in keyof Tuple]: Dispatcher; }): Augmented<(this: Encoder, value: Tuple) => void>; recall(index: number): Augmented<(this: Encoder, value: object) => void>; instance(name: string): Augmented<(this: Encoder, value: object) => void>; /** * --- Objects */ private properties; object(properties: PropertiesDispatcher): Augmented<(this: Encoder, value: O) => void>; array(dispatch: Dispatcher): Augmented<(this: Encoder, value: T[]) => void>; array(dispatch: Dispatcher, properties: PropertiesDispatcher

): Augmented<(this: Encoder, value: T[] & P) => void>; set(dispatch: Dispatcher): Augmented<(this: Encoder, value: Set) => void>; set(dispatch: Dispatcher, properties: PropertiesDispatcher

): Augmented<(this: Encoder, value: Set & P) => void>; map([keyDispatcher, valueDispatcher]: [Dispatcher, Dispatcher]): Augmented<(this: Encoder, value: Map) => void>; map([keyDispatcher, valueDispatcher]: [Dispatcher, Dispatcher], properties: PropertiesDispatcher

): Augmented<(this: Encoder, value: Map & P) => void>; /** * Encode the given dispatcher's schema */ schema(dispatcher: Dispatcher): void; private schemaProperties; }