Socket
Socket
Sign inDemoInstall

before

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

before

before decorator factory


Version published
Weekly downloads
630
decreased by-84.8%
Maintainers
1
Weekly downloads
 
Created
Source

before

before decorator factory

Installation

npm install before

Example

var before = require('before');

// an object with some method
var speak = {
  greeting: 'welcome',
  greet: function(a, b, fn){
    fn(null, a + ' ' + b);
  }
};

// factory before hook method
speak.before = before(speak);

// before greet
speak.before('greet', function(args, fn){
  args[0] = args[0] + ' to this wonderful';
  fn();
});

// one more, this will run first
speak.before('greet', function(args, fn){
  args[0] = args[0] + ', ' + this.greeting;
  fn();
});

// runs mutation hooks, then greets
speak.greet('Human', 'world!', function(err, result){
  console.log(result); // => Human, welcome to this wonderful world!
});

API

before(context)

Captures context to be used by decorator.

before(method, outer)

Decorates method using outer.

outer is called with (args, fn) to allow arguments mutation.

License

MIT

Keywords

FAQs

Package last updated on 21 Nov 2013

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc