UNPKG

@codeplaydata/datasus

Version:

This application decompress the datasus micro data and serve as a gateway class.

48 lines (47 loc) 1.7 kB
import { DBFFile, FieldDescriptor } from 'dbffile'; /** * Wrapper around dbffile to handle DATASUS DBC files conversion and reading. * * It converts the .dbc file to a temporary .dbf (using @codeplaydata/dbc2dbf), * exposes basic metadata (record count and fields) and provides iteration helpers. */ export declare class Dbc { readonly dbf: DBFFile; private readonly io; /** Total number of records in the dataset. */ size: number; /** Field descriptors as reported by dbffile. */ fields: FieldDescriptor[]; /** * @param dbf Opened DBFFile instance. * @param io Input/output paths used for conversion and temp file storage. */ private constructor(); /** * Loads a .dbc file, converting it to a temporary .dbf if necessary. * @param inputFile Full path to the .dbc file. * @returns A ready-to-use Dbc wrapper instance. */ static load(inputFile: string): Promise<Dbc>; /** * Reads a batch of records from the DBF. * @param count Optional number of records to read (defaults to all records). */ readBatch(count?: number): Promise<Record<string, unknown>[]>; /** * Deletes the temporary .dbf file created during conversion. */ remove(): void; /** * Iterates through each record asynchronously, invoking the callback. * @param callback Async function receiving each record. */ forEachRecords(callback: (record: any) => Promise<any>): Promise<void>; } /** * Error thrown when the temporary .dbf file cannot be removed. */ export declare class CanNotExcludeDbcFile extends Error { constructor(file: string); static exception(file: string): void; }