/** * The writer module * * @module writer */ import { BinaryCursorEndianness } from './cursor.ts'; import { InstantiableObject } from './types.ts'; interface BinwriteOptions { endian?: BinaryCursorEndianness; } /** * `binwrite` transforms a binspector definition instance into an * `ArrayBuffer`. * * @example * * Given the following protocol definition: * * ```typescript * class Protocol { * @Uint8 * x: number * * @Uint8 * y: number * } * ``` * * There are two ways to call the `binwrite` function: * * - Pass an instance of the `Protocol` class to binwrite: * * ```typescript * const protocol = new Protocol() * protocol.x = 1 * protocol.y = 2 * * binwrite(protocol) // => ArrayBuffer { [Uint8Contents]: <01 02>, byteLength: 2 } * ``` * * - Pass an object that represent the definition with the definition * constructor * * ```typescript * const protocol = { x: 1, y: 2 } * * binwrite(protocol, Protocol) // => ArrayBuffer { [Uint8Contents]: <01 02>, byteLength: 2 } * ``` * * @param {Target} instance Object or definition instance to serialize. * @param {InstantiableObject | Partial} ObjectDefinitionOrOpt * @param {Partial} opt * * @returns {ArrayBufferLike} The serialized object buffer. */ export declare function binwrite(instance: Target, ObjectDefinitionOrOpt?: InstantiableObject | Partial, opt?: Partial): ArrayBufferLike; /** * `computeBinSize` compute the size in byte of a binspector declaration * instance. * * @param {Target} instance Binspector declaration instance. * * @returns {number} Size in byte. */ export declare function computeBinSize(instance: Target | Target[]): number; export {};