- pre-hooks - post-hooks -

npm install mediocre
75 downloads in the last day
267 downloads in the last week
545 downloads in the last month

Mediocre.js Alt ci

Mediocre is a lightweight JavaScript mediator.


  • ability to add pre / post hooks
  • ability to call commands with options (see below)
var mediator = require("mediocre")();

mediator.on("validate", function (message, next) {
    for(var param in message.options) {
      //validate fields against

//login helper
mediator.on("login", function (message, next) {

//add pre-hook into login to validate fields
mediator.on("pre login", { validate: { username: "string", password: "string" }});


mediator.on(event, listeners...)

adds a listener

mediator.execute(listener[, data][, callback])

executes a command

message mediator.message(name[, data][, options])

creates a new message option to dispatch

mediator.on("hello", function(message, options) {
  console.log(message.options.message); // world!

mediator.on("sayHelloWorld", { hello: { message: "world!" }});

//executes hello with options world
mediator.execute(mediator.message("hello", null, { message: "world!" }));

//same as above command
npm loves you