UNPKG

@midlandsbank/node-nacha

Version:

NACHA ACH EFT File Parser/Formatter for CCD+ / PPD+ / CTX+

87 lines (80 loc) 2.32 kB
// Generated by CoffeeScript 1.11.1 var getTransform, setTransform, transforms; transforms = { parsers: { ach: require('./ach-parser'), json: require('./json-parser') }, formatters: { ach: require('./ach-formatter'), json: require('./json-formatter') } }; getTransform = function(format, which) { if (!((format != null) && (which != null))) { return; } format = format.toLowerCase(); return transforms[which][format] }; /* getTransform = function(format, which) { var error, otherModule, ref, ref1, transform; if (!((format != null) && (which != null))) { return; } format = format.toLowerCase(); transform = transforms != null ? (ref = transforms[which]) != null ? ref[format] : void 0 : void 0; if (transform != null) { return new transform; } else { try { otherModule = require('@ach/' + format); transform = otherModule != null ? (ref1 = otherModule[which]) != null ? ref1[format] : void 0 : void 0; if (transform != null) { transforms[which][format] = transform; return new transform; } } catch (error1) { error = error1; } } }; */ setTransform = function(format, transform, which) { var error; format = format != null ? typeof format.toLowerCase === "function" ? format.toLowerCase() : void 0 : void 0; if ((format != null) && (transform != null)) { transforms[which][format] = transform; } else { return error = { error: 'must specify both format and transform', format: format, transform: transform }; } }; module.exports = { getParser: function(format) { return getTransform(format, 'parsers'); }, getFormatter: function(format) { return getTransform(format, 'formatters'); }, setParser: function(format, transform) { return setTransform(format, transform, 'parsers'); }, setFormatter: function(format, transform) { return setTransform(format, transform, 'formatters'); }, parserFormats: function() { return Object.keys(transforms.parsers); }, formatterFormats: function() { return Object.keys(transforms.formatters); }, hasParser: function(format) { return transforms.parsers[format] != null; }, hasFormatter: function(format) { return transforms.formatters[format] != null; } };