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

node-pluggable

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pluggable

Add your Hook more easily.

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

node-pluggable

Add your Hook more easily.

Build Status Coverage Status

Demo

  • lyssa

Installation

npm install node-pluggable

API

Pluggable = require 'node-pluggable'
pluggable = new Pluggable()

use([match_param ,] hook_callback...) => this

pluggable.use('article.create', (article, next) ->
  article.hook = 'article.create'
  next()
)
  • this method is similar to connect
  • match_param must be string or regex
  • hook_callback will be called when param is matched
run(param, hook_callback_params...[, callback]) => this
article =
  title: 'title'
  author: 'author'
  content: 'content'

pluggable.run 'article.create', article, ->
  console.log article
  • param will match with match_param, which must be string
  • hook_callback_params will be send to hook_callback

del([match_param ,] hook_callback...) => this

pluggable.del('article.create', (article, next) ->
  article.hook = 'article.create'
  next()
)
  • reverse of use

bind(hook_name, hook_callback...) => this

pluggable.bind 'article.update', (article) ->
  console.log article
, (article) ->
  console.log article.length
  • hook_callback will be called when event be emitted

on(hook_name, hook_callback) => this

pluggable.on 'article.update', (article) ->
  console.log article
  • similar to bind

emit(hook_name, data) => this

pluggable.emit 'article.update', 'just a message.'
  • emit an event

License

MIT

FAQs

Package last updated on 21 Apr 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