JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29320
  • Score
    100M100P100Q131237F
  • License MIT

Upgrade's plugin support in base-methods to allow plugins to be called any time after init.

Package Exports

  • base-plugins

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-plugins) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-plugins NPM version

Upgrade's plugin support in base-methods to allow plugins to be called any time after init.

What does this do?

This lib itself is a actually a plugin for base-methods. Natively, base methods supports plugins that registered with the use method and are only called once upon init.

By adding this plugin, plugins that return a function will be pushed onto a plugins array, and may be called later with the run method.

Install

Install with npm

$ npm i base-plugins --save

Usage

var plugins = require('base-plugins');
var Base = require('base-methods');
var base = new Base();

// register `plugins` as a plugin
base.use(plugins);

Now, to run all registered plugins on a given object, do:

var foo = {};
base.run(foo);

API

.use

Define a plugin function to be called immediately upon init. The only parameter exposed to the plugin is the application instance.

Also, if a plugin returns a function, the function will be pushed onto the plugins array, allowing the plugin to be called at a later point, elsewhere in the application.

Params

  • fn {Function}: plugin function to call
  • returns {Object}: Returns the item instance for chaining.

Example

// define a plugin
function foo(app) {
  // do stuff
}

// register plugins
var app = new Base()
  .use(foo)
  .use(bar)
  .use(baz)

.run

Run all plugins

Params

  • value {Object}: Object to be modified by plugins.
  • returns {Object}: Returns the item instance for chaining.

Example

var config = {};
app.run(config);

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on October 10, 2015.