Socket
Socket
Sign inDemoInstall

use

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use

Easily add plugin support to your node.js application.


Version published
Weekly downloads
8.5M
decreased by-16.96%
Maintainers
2
Weekly downloads
 
Created
Source

use NPM version

Easily add plugin support to your node.js application.

Install

Install with npm

$ npm i use --save

Usage

var use = require('use');

API

.use

Define a plugin function to be passed to use. 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 fns 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

var use = require('use');

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

var app = function(){};
use(app);

// register plugins
app.use(foo);
app.use(bar);
app.use(baz);

.run

Run all plugins on fns. Any plugin that returns a function when called by use is pushed onto the fns array.

Params

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

Example

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

Similar projects

  • base-methods: Starter for creating a node.js application with a handful of common methods, like set, get,… more | homepage
  • ware: Easily create your own middleware layer. | homepage

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 November 10, 2015.

FAQs

Package last updated on 10 Nov 2015

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