New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

bloody-functionhook

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

bloody-functionhook

hooks on function calls

latest
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
Source

function hook

Build Status

browser support

install

$ npm install bloody-functionhook

require

var hook = require("bloody-functionhook")

api

hook(object, propertyName) > notifier

replaces object[propertyName] by the hook function, and returns a notifier.

notifier

notifier.on(event, cb)
  • "arguments" fires when the arguments are accessible to the hook function
  • "error" fires if an error occurred
  • "call" fires when the function is called
  • "return" fires when the function has a result

notifier.count (int)

the times the function was called

notifier.emit("destroy")

removes the hook

example

var view = cornea.extend({
  getInitialData : function(){
    return {
      foo : ""
    }
  },
  template : function(data){
    return "<div></div>"
  }
})

var notifier = hook(view, "template")
var data = {
  foo : "bar"
}
notifier.on("arguments", function(args){
  test.equal(args[0], data, "data is passed")
  test.end()
})
view.update(data)

FAQs

Package last updated on 27 Jun 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