summaryrefslogtreecommitdiffstats
path: root/lib/output/callHook.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/callHook.js')
-rw-r--r--lib/output/callHook.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/output/callHook.js b/lib/output/callHook.js
index 1ff1a41..4914e52 100644
--- a/lib/output/callHook.js
+++ b/lib/output/callHook.js
@@ -1,4 +1,5 @@
var Promise = require('../utils/promise');
+var timing = require('../utils/timing');
var Api = require('../api');
function defaultGetArgument() {
@@ -30,26 +31,30 @@ function callHook(name, getArgument, handleResult, output) {
// Create the JS context for plugins
var context = Api.encodeGlobal(output);
- // Get the arguments
- return Promise(getArgument(output))
-
- // Call the hooks in serie
- .then(function(arg) {
- return Promise.reduce(plugins, function(prev, plugin) {
- var hook = plugin.getHook(name);
- if (!hook) {
- return prev;
- }
-
- return hook.call(context, prev);
- }, arg);
- })
-
- // Handle final result
- .then(function(result) {
- output = Api.decodeGlobal(output, context);
- return handleResult(output, result);
- });
+ return timing.measure(
+ 'call.hook.' + name,
+
+ // Get the arguments
+ Promise(getArgument(output))
+
+ // Call the hooks in serie
+ .then(function(arg) {
+ return Promise.reduce(plugins, function(prev, plugin) {
+ var hook = plugin.getHook(name);
+ if (!hook) {
+ return prev;
+ }
+
+ return hook.call(context, prev);
+ }, arg);
+ })
+
+ // Handle final result
+ .then(function(result) {
+ output = Api.decodeGlobal(output, context);
+ return handleResult(output, result);
+ })
+ );
}
module.exports = callHook;