interject
deprecated
This module is deprecated. Use call-hook instead. It's much better.
Do something as an aside to a callback.
Potentially useful for logging calls to particular callbacks. Maybe other stuff too.
example
var interject = ; var { console; if cb ;}; var { console;}; var { console;}; ;// Output:// Interject me please.// You said: Interject me please. var sayLogged = ;;// Output:// Interject me please.// On Fri Mar 28 2014 18:20:41 GMT-0400 (EDT), somebody said: Interject me please.// You said: Interject me please.
api
var f = interject(func, function interjection () {})
;
Assuming the implementation of func
accepts a callback (as it's last parameter), the function returned by
interject
will invoke both the interjection
(as an aside) and the callback
provided to f
at the
time the func
implementation would have executed it's callback. It's important to note that the interjection
will be
called just before the callback
, but it is not gauranteed to complete before callback
is called.
The interjection
receives the same arguments
as the callback
.
Also of note - when nesting interjections, the interjections will be called in the order they are defined before the final
callback
. Example:
var { };var { /* I am called 1st */ };var f = ;var { /* I am called 2nd */ };var f = ;;
install
npm install interject
testing
npm test [--dot | --spec] [--coverage | --grep=pattern]
Specifying --dot
or --spec
will change the output from the default TAP style.
Specifying --coverage
will print a text coverage summary to the terminal after
tests have ran, while --pattern
will only run the test files that match the given
pattern.
Open an html coverage report with npm run view-cover
.