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

use-plugin

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-plugin

Generic plugin loader functionality for Node.js frameworks.

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.1K
increased by34.33%
Maintainers
1
Weekly downloads
 
Created
Source

use-plugin

Generic plugin loader functionality for Node.js frameworks.

There is annotated source code for this module.

For use in framework modules to provide a plugin mechanism for extensions. While a simple require in calling code is a good start, this plugin provides some convenience abstractions over vanilla requires so that you can offer a more user-friendly interface.

See the seneca module for an example of practical usage.

Quick example

// myframework.js
module.exports = function() {
  var use = require('use-plugin')({prefix:'foo',module:module})
  return {
    use: function( plugin_name ) {
      var plugin_properties == use(plugin_name)
      
      // call the init function to init the plugin
      plugin_properties.init()
    }
  }
}

// callingcode.js
var fm = require('myframework')

// this will try to load:
// 'bar', 'foo-bar', './foo', './foo-bar'
// against the framework module, and then the callingcode module
// nice error messages are thrown if there are problems
fm.use('bar')

Usage

The module provides a builder function that you call with your desired options. In particular, you should always set your module, as above.

The builder function returns a plugin loader function that you can use inside your framework. Calling the loader function returns an object with properties that describe the plugin.

In particular, the point of this module is to resolve (via require), the init function of the plugin, so that you can call it in your framework.

See the annotated source code for full details.

Support

If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger

Current Version: 0.1.4

Tested on: node 0.10.26

Build Status

Keywords

FAQs

Package last updated on 26 May 2014

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