Skip to content

Instantly share code, notes, and snippets.

@jnv
Last active October 26, 2018 10:49
Show Gist options
  • Save jnv/e26ee6b3b3715765c9a435d9fe620d1e to your computer and use it in GitHub Desktop.
Save jnv/e26ee6b3b3715765c9a435d9fe620d1e to your computer and use it in GitHub Desktop.
BakeryJS Example Component (wordcount)
const {boxFactory} = require('bakeryjs');
module.exports = boxFactory(
// name
'wordcount',
// metadata
{
provides: ['words'],
requires: ['text'],
emits: [],
aggregates: false,
},
// body
function(serviceProvider, message) {
const wordsCount = message.text.split(/\W+/).length;
return {words: wordsCount};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment