mt940parser/ts/index.ts

26 lines
778 B
TypeScript
Raw Normal View History

import * as plugins from './mt940parser.plugins.js';
export class Mt940Parser {
public async parseMt940FileString(fileStringArg: string) {
// console.log(fileStringArg);
const textEncode = new TextEncoder();
const statements = await this.parseMt940Buffer(textEncode.encode(fileStringArg).buffer);
return statements;
}
public async parseMt940Buffer(fileBufferArg: ArrayBufferLike) {
// console.log(fileStringArg);
const textEncode = new TextEncoder();
const statements = await plugins.mt940Js.read(fileBufferArg);
// bank afterburner
for (const statement of statements) {
if (statement.referenceNumber === "BUNQ BV") {
statement.accountId = statement.accountId.split(' ')[0];
}
}
return statements;
}
}