UNPKG

fedach

Version:

Parse FedACH Directory File Format

61 lines (53 loc) 1.44 kB
// Generated by CoffeeScript 1.12.4 (function() { var regex, request; request = require('request'); /* * FedACH Directory File Format * https://www.fededirectory.frb.org/download.cfm */ regex = /^(.{9})(.{1})(.{9})(.{1})(.{6})(.{9})(.{36})(.{36})(.{20})(.{2})(.{5})(.{4})(.{3})(.{3})(.{4})(.{1})(.{1})(.{5})$/; exports.download = function(cb) { return request({ url: 'https://www.frbservices.org/EPaymentsDirectory/FedACHdir.txt' }, function(err, res, body) { if (err) { return cb(err); } return cb(null, body); }); }; exports.parse = function(data) { var line, lines, r, records; records = []; lines = data.split('\r\n'); while (line = lines.shift()) { r = regex.exec(line); if (r) { records.push({ routing: r[1], office: r[2], frb: r[3], type: r[4], date: r[5], newRouting: r[6], customer: r[7].trim(), address: r[8].trim(), city: r[9].trim(), state: r[10], zip: r[11], zipExt: r[12], zipFull: r[11] + "-" + r[12], phoneArea: r[13], phonePrefix: r[14], phoneSuffix: r[15], phoneFull: "" + r[13] + r[14] + r[15] + "", status: r[16], dataView: r[17], filter: r[18] }); } } return records; }; }).call(this);