Hooks(optsopt)

Provides hook mechanics.

Constructor

new Hooks(optsopt)

Parameters:
Name Type Description
optsopt object
Properties
Name Type Default Description
onlyopt
  • string
  • boolean
false
  • 'first': Only allows 1 function per hook
  • 'last': Only invokes the last function added
  • false: Accepts any number of functions (default)
Author:
Satoshi Soma (amekusa.com)
License:
Apache-2.0
Copyright 2020 Satoshi Soma

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Source:
lib/Hooks.js, line 19

Methods

add(hooks)

Adds hook function(s).

Parameters:
Name Type Description
hooks object

Key = hook name, Value = function

Source:
lib/Hooks.js, line 35

apply(key, value, …argsoptrpt)any

Modifies the given value with the hook functions associated with the given key.

Parameters:
Name Type Description
key string
value any

Value to pass to the functions

argsoptrpt any

Additional args to pass to the functions

Source:
lib/Hooks.js, line 61
Returns:

Modified value

Type:
any

do(key, …argsoptrpt)

Invokes the hook functions associated with the given key.

Parameters:
Name Type Description
key string
argsoptrpt any

Args to pass to the functions

Source:
lib/Hooks.js, line 46

has(key)boolean

Returns whether any hook function associated with the given key exists.

Parameters:
Name Type Description
key string
Source:
lib/Hooks.js, line 75
Returns:
Type:
boolean

Licensed under the Apache License 2.0

Documentation generated by JSDoc 4.0.2 using Docolatte theme