Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broadway

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broadway

Lightweight application extensibility and composition with a twist of feature reflection.

  • 0.2.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-83.48%
Maintainers
2
Weekly downloads
 
Created
Source

broadway Build Status

Lightweight application extensibility and composition with a twist of feature reflection.

Example

app.js

var broadway = require("broadway");

var app = new broadway.App();

// Passes the second argument to `helloworld.attach`.
app.use(require("./plugins/helloworld"), { "delimiter": "!" } );

app.init(function (err) {
  if (err) {
    console.log(err);
  }
});

app.hello("world");

plugins/helloworld.js

// `exports.attach` gets called by broadway on `app.use`
exports.attach = function (options) {

  this.hello = function (world) {
    console.log("Hello "+ world + options.delimiter || ".");
  };

};

// `exports.init` gets called by broadway on `app.init`.
exports.init = function (done) {

  // This plugin doesn't require any initialization step.
  return done();

};

run it!

josh@onix:~/dev/broadway/examples$ node simple/app.js 
Hello world!
josh@onix:~/dev/broadway/examples$ 

Installation

Installing npm (node package manager)

  $ curl http://npmjs.org/install.sh | sh

Installing broadway

  $ [sudo] npm install broadway

API

App#init(callback)

Initialize application and it's plugins, callback will be called with null or initialization error as first argument.

App#use(plugin, options)

Attach plugin to application. plugin should conform to following interface:

var plugin = {
  "name": "example-plugin", // Plugin's name

  "attach": function attach(options) {
    // Called with plugin options once plugin attached to application
    // `this` - is a reference to application
  },

  "detach": function detach() {
    // Called when plugin detached from application
    // (Only if plugin with same name was attached)
    // `this` - is a reference to application
  },

  "init": function init(callback) {
    // Called on application initialization
    // App#init(callback) will be called once every plugin will call `callback`
    // `this` - is a reference to application
  }
};

App#on(event, callback) and App#emit(event, data)

App inherits from EventEmitter2, and many plugins build on this functionality.

Built-In Events:
  • error:init: Broadway emits this event when it throws an error while attempting to initialize.

Read the EventEmitter2 documentation for more information.

Tests

All tests are written with vows and should be run with npm:

  $ npm test
Charlie Robbins
License: MIT

FAQs

Package last updated on 23 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc