@midlandsbank/node-nacha
Version:
NACHA ACH EFT File Parser/Formatter for CCD+ / PPD+ / CTX+
64 lines (58 loc) • 1.67 kB
JavaScript
// Generated by CoffeeScript 1.11.1
var to, transforms;
transforms = require('../transforms');
module.exports = to = function(format = 'ach') {
if(typeof format !== 'string') throw new Error('format must be of type string')
lowerCaseFormat = format.toLowerCase()
const formatter = transforms.getFormatter(lowerCaseFormat)
if(!formatter) throw new Error(`${format} is not a valid format`)
return formatter(this.data)
};
/* module.exports = to = function(options) {
var event, nextStream, objectTransform, target;
if (options == null) {
options = {};
}
if ('string' === typeof options) {
options = {
format: options,
target: process.stdout
};
} else if (isStream(options)) {
options = {
format: 'ach',
target: options
};
}
if (options.format == null) {
options.format = 'ach';
}
if ((options != null ? options.format : void 0) != null) {
objectTransform = transforms.getFormatter(options.format);
if (objectTransform != null) {
this.streams.unshift(objectTransform);
} else {
return {
error: 'invalid \'to\' format: ' + options.format
};
}
}
if ('function' === typeof options.target) {
if (options.format != null) {
this.streams.unshift(strung());
event = 'finish';
} else {
event = 'data';
}
streams[0].on(event, listener);
} else {
this.streams.unshift(target = isStream(options.target) ? options.target : process.stdout);
}
nextStream = this.streams.pop();
while (this.streams.length !== 0) {
nextStream = nextStream.pipe(this.streams.pop());
}
return {
success: true
};
}; */