Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
making our node implementation to output data for export
let textUtils = require('@redsift/text-utilities');
module.exports = function (got) {
// got.in contains the key/value pairs that match the given query
const inData = got.in;
console.log('counter: node1.js: running...', inData.data);
const json = inData.data.map(d => JSON.parse(d.value));
const others = json.filter(j => j.user !== j['from'].email);
let counts = others.map(value => {
let text = value.textBody || value.strippedHtmlBody || '';
let count = textUtils.splitWords(textUtils.trimEmailThreads(text)).length;
return {
key: 'word_count',
value: count
}
});
console.log('counter: node1.js: will output:', counts);
return counts;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment