@xwordly/xword-parser
Version:
Fast, type-safe TypeScript library for parsing crossword puzzles (PUZ, iPUZ, JPZ, XD)
29 lines (26 loc) • 1.18 kB
TypeScript
import { P as ParseOptions, a as Puzzle } from './types-BPKJZKk0.js';
/**
* Parse a crossword puzzle asynchronously with dynamic imports for smaller bundle size.
* Parsers are loaded only when needed, reducing initial bundle size.
*
* @param data - The puzzle data as string, Buffer, or ArrayBuffer
* @param options - Optional parsing options
* @param options.filename - Filename hint to improve format detection
* @param options.encoding - Character encoding for text formats (default: 'utf-8')
* @param options.maxGridSize - Maximum allowed grid dimensions
* @returns A Promise that resolves to a unified Puzzle object
* @throws {FormatDetectionError} When the format cannot be detected
* @throws {ParseError} When parsing fails for the detected format
*
* @example
* ```typescript
* import { parseLazy } from 'xword-parser/lazy';
* import { readFileSync } from 'fs';
*
* const content = readFileSync('puzzle.ipuz');
* const puzzle = await parseLazy(content, { filename: 'puzzle.ipuz' });
* console.log(puzzle.title);
* ```
*/
declare function parseLazy(data: string | Buffer | ArrayBuffer, options?: ParseOptions): Promise<Puzzle>;
export { parseLazy };