Skip to content
Simple function lifecycle hooks
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
source
tests
.gitignore
.jshintrc
.npmignore
LICENSE
README.md
package.json

README.md

Hookie

Simple function lifecycle hooks. Creates functions that call named hooks before and after each function calls.

Hookie(name, func, options)

Creates a wrapped function that will call hooks before and after it is called.

Example

var person = {
  beforeSlap: function () { log('before') },

  slap: Hookie('slap', function (name) {
    log('slap!')
  }),

  afterSlap: function () { log('after') }
}

person.slap()
// before
// slap!
// after

Options

type

default value: 'Prefix' Possible values: 'prefix', 'postfix'

Changes where hook term is placed in terms of the hook name.

Hookie(name, func, { type: 'postfix' })

capitalize

default value: true Possible values: true, false

Switch that decides whether callback functions have a captalized naming scheme.

Hookie(name, func, { capitalize: true })

before

default value: 'before'

Defines the term used when building the before-hook name.

Hookie(name, func, { before: 'pre' })

after

default value: 'after'

Defines the term used when building the after-hook name.

Hookie(name, func, { after: 'post' })
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.