dynamic-hooks
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

dynamic-hooks

Overview

Provides a cleaner implementation for "hooking" functions.

How to install:

npm i dynamic-hooks

How to use:

Code:

// Import the module after installation.
const dhook = require('dynamic-hooks').DynamicHooks;

// An example object, can be anything.
const myObj = {
  myFunction() {
    console.log('2');
  }
}

// Hooking into the method with dynamic-hooks.
// !! Args: Target object, name of the target function, your hook function.
dhook.hookBefore(myObj, 'myFunction', () => {
  console.log('1');
});

// Call the method
myObj.myFunction();

Log:

1
2

Package Sidebar

Install

npm i dynamic-hooks

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

4.25 kB

Total Files

4

Last publish

Collaborators

  • maowimpl