Skip to content

dimebox/mt940-js

 
 

Repository files navigation

mt940-js

Build Status npm npm Coverage Status

An isomorphic Javascript library for working with MT940 format

Reading

API

read(buffer)

  • buffer {Buffer|ArrayBuffer} - income buffer that contains data of mt940 file.
  • returns Promise with list of Statement.

Node.js environment

import * as mt940 from 'mt940-js';
import fs from 'fs';

fs.readFile('/path/to/your/mt940/file', (error, buffer) => {
    mt940.read(buffer).then((statements) => {
        //
    });
});

Browser environment

Reading a local file

<input type="file" onchange="onFileSelected(this.files[0])"/>
import * as mt940 from 'mt940-js';

function onFileSelected (file) {
    const reader = new FileReader();
    
    reader.onload = () => {
        mt940.read(reader.result).then((statements) => {
            // List of the Statements
        });
    };
    reader.readAsArrayBuffer(file);
}

Reading a remote file

import * as mt940 from 'mt940-js';

fetch('/url/to/mt940/file')
    .then((response) => response.arrayBuffer())
    .then((buffer) => {
        mt940.read(buffer).then((statements) => {
            // List of the Statements
        });
    });

Writing

Coming soon

Supported MT940 tags

  • :20:
  • :21:
  • :25:
  • :28(C):
  • :60(M|F):
  • :61:
  • :62(M|F):
  • :64:
  • :65:
  • :86:

Related links

JS

mt940 specification

About

A mt940 isomorphic Javascript parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 53.7%
  • TypeScript 46.3%