docparse-supplier-nge
Version:
process ngrid electric utility bill data for use in the docparse system
18 lines (17 loc) • 384 B
JavaScript
var extract = require('regex-extract');
module.exports = function(text, cb) {
var pattern = /Total Energy\s* (-?\s?[\d\.]+) kWh\s*$/m;
extract(text, pattern, function (err, reply) {
if (err) {
return cb(err, null);
}
if (!reply) {
reply = '0';
}
var output = {
quantity: reply,
units: 'kwh'
};
return cb(null, output);
});
};