hmu-core
Run HMU requests and get raw output
This module is for running HMU requests (otherwise called plugins) and getting raw output.
If you are looking for a CLI version, see hmu
.
This module is for using the same easy function for different displays like chat, web, email, etc.
Installation
$ npm install --save hmu-core
Usage
hmu(requests, [callback])
Runs the given requests
and gives the mapped results in callback
.
Parameters
requests
(Array
): An array of "request objects" in the form{ target, input, options }
callback
(Function
): Collected results. Called with params(err, res)
.res
being a map ofrequests
.
Examples
request
A request
is a plain object in the form:
target: Function input: Array // optional (undefined, null) options: Array // optional
A target
is otherwise called a "plugin". A plugin is more on the front-end side as it gets resolved into a target (which then gets ran). This is so you can do dynamic plugins, e.g. a function loaded as a target from chat messages.
plugin
A plugin gets called with target(input, options, callback)
. input
and options
are from request
if ran with hmu-core
, but this form makes them reusable as any normal function.
The callback
is called in (err, output)
. You can think of output
as a map or reduce of input
, and your options
can trigger varying output alongside that.
Examples
// Simple HTTP fetch plugin using `pull-stream` and `pull-fetch` { }
License
MIT © Jamen Marz