code: function addHook(hooks, hook) {
      hooks.push(hook)
      return function () {
        var i = hooks.indexOf(hook)
        if (i >= 0) return hooks.splice(i, 1)
      }
    }
docs: helper to register pre and post commit hooks