1.0.0 • Published 10 years ago

@slicemenice/js-hooks v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

JS Hooks

Manage filter and actions hooks in JavaScript.

API Usage

API functions can be called via the global hooks like this hooks.addAction(...), etc.

  • addAction( 'namespace.identifier', callback, priority )
  • addFilter( 'namespace.identifier', callback, priority )
  • removeAction( 'namespace.identifier' )
  • removeFilter( 'namespace.identifier' )
  • doAction( 'namespace.identifier', arg1, arg2, moreArgs, finalArg )
  • applyFilters( 'namespace.identifier', content )

Features

  • Priorities system ensures hooks with lower integer priority are fired first.
  • Uses native object hash lookup for finding hook callbacks.
  • Utilizes insertion sort for keeping priorities correct. Best Case: O(n), worst case: O(n^2)

Release History

1.0.0