Last active
October 26, 2018 10:49
-
-
Save jnv/e26ee6b3b3715765c9a435d9fe620d1e to your computer and use it in GitHub Desktop.
BakeryJS Example Component (wordcount)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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