module.exports = async function(angel) {
angel.on(pattern, async function(angel){
})
}
- autoloads angel modules from
process.cwd() + '/node_modules'
folder
Returns cloned object of Angel instance keeping references to:
angel.reactor
angel.plasma
angel.env.cwd
-
pattern
: String with placeholders like 'echo :value' or RegExp -
handler
:async function(angel)
, whereangel
: cloned Angel Object withcmdData
cmdData
: Object containing the resulted match ofpattern
-
Returns
microApi
instance
Example:
angel.on("tell me about :topic in :section", function(angel){
console.log("You asked about topic:"+angel.cmdData.topic)
console.log("And section:"+angel.cmdData.section)
})
// or
angel.on(/tell me about (.*)/, function(angel){
console.log("You asked about "+angel.cmdData[1])
})
Same as angel.on
but will handle the pattern only once.
handler
won't be fired for pattern
used in angel.on
or angel.once
command
: String like 'echo test'
Adds a default handler, will be invoked if none handler matched given angel.do
input command
handler
: async Function (input: String)