UNPKG

gcash-pdf-parser

Version:

Extract GCash transaction data from PDF statements

53 lines (52 loc) 2.33 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GCashPDFParser = void 0; exports.parseGCashPDF = parseGCashPDF; exports.parseGCashPDFtoCSV = parseGCashPDFtoCSV; const GCashPDFParser_1 = require("./parsers/GCashPDFParser"); Object.defineProperty(exports, "GCashPDFParser", { enumerable: true, get: function () { return GCashPDFParser_1.GCashPDFParser; } }); /** * Parse a GCash PDF and extract transactions * * @param pdfData - The PDF file data as an ArrayBuffer * @param password - The password to decrypt the PDF * @param options - Optional configuration * @returns A Promise resolving to an array of transactions */ function parseGCashPDF(pdfData, password, options) { return __awaiter(this, void 0, void 0, function* () { const parser = new GCashPDFParser_1.GCashPDFParser(pdfData, password, options); yield parser.parse(); return parser.getTransactions(); }); } /** * Parse a GCash PDF and convert to CSV string * * @param pdfData - The PDF file data as an ArrayBuffer * @param password - The password to decrypt the PDF * @param options - Optional configuration * @returns A Promise resolving to a CSV string */ function parseGCashPDFtoCSV(pdfData, password, options) { return __awaiter(this, void 0, void 0, function* () { const parser = new GCashPDFParser_1.GCashPDFParser(pdfData, password, options); yield parser.parse(); return parser.toCSV(); }); } // Create a default export for easier browser usage exports.default = { GCashPDFParser: GCashPDFParser_1.GCashPDFParser, parseGCashPDF, parseGCashPDFtoCSV, };