UNPKG

@andrew_l/tl-pack

Version:

Another implementation of binary serialization.

30 lines (27 loc) 1.13 kB
import { B as BinaryWriterOptions, a as BinaryReaderOptions } from './shared/tl-pack.DM1wAuup.cjs'; export { b as BinaryReader, c as BinaryWriter, C as CORE_TYPES, D as DecodeHandler, f as DefineStructureOptions, E as EncodeHandler, M as MAX_BUFFER_SIZE, S as Structure, T as TLExtension, d as createDictionary, e as createExtension, g as defineStructure } from './shared/tl-pack.DM1wAuup.cjs'; import '@andrew_l/toolkit'; /** * Encode any value into `Uint8Array` * * @example * const buffer = tlEncode(new Date(0)); * * console.log(buffer); // Uint8Array([5, 0, 0, 0, 0, 0, 0, 0, 0]) * * @group Main */ declare function tlEncode(value: unknown, opts?: BinaryWriterOptions): Uint8Array; /** * Decode value from `Uint8Array` * * @example * const buffer = new Uint8Array([5, 0, 0, 0, 0, 0, 0, 0, 0]); * const value = tlDecode(buffer); * * console.log(value); // Thu Jan 01 1970 01:00:00 GMT+0100 (Central European Standard Time) * * @group Main */ declare function tlDecode<T = any>(buffer: Uint8Array, opts?: BinaryReaderOptions): T; export { BinaryReaderOptions, BinaryWriterOptions, tlDecode, tlEncode };