import type { ParsedValue, SchemaNode } from '../types/Parser'; import type { Registry } from '../types/Registry'; import Cursor from './Cursor'; /** * Abstract Parser. * * TypeScript version by Logue. * Original version written by HybridEidolon's saredit * @see https://github.com/HybridEidolon/saredit */ export default abstract class AbstractParser { protected readonly decoder: TextDecoder; /** * Get parsed struct * @param buffer - buffer to parse * @param schema - schema to parse with * @param registries - registries of schemas or parsers to use (including base registry) */ parse(buffer: ArrayBuffer, schema: SchemaNode, registries?: Partial[]): ParsedValue; /** * Goes through a schema object and fill its data in order based on cursor and registry * @param payload - attributes to parse */ parseAttribute({ cursor, schema, registry, }: { cursor: Cursor; schema: SchemaNode; registry: Partial; }): ParsedValue; }