MCPcopy Index your code
hub / github.com/nodejs/node / enable

Method enable

lib/async_hooks.js:108–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106 }
107
108 enable() {
109 // The set of callbacks for a hook should be the same regardless of whether
110 // enable()/disable() are run during their execution. The following
111 // references are reassigned to the tmp arrays if a hook is currently being
112 // processed.
113 const { 0: hooks_array, 1: hook_fields } = getHookArrays();
114
115 // Each hook is only allowed to be added once.
116 if (ArrayPrototypeIncludes(hooks_array, this))
117 return this;
118
119 const prev_kTotals = hook_fields[kTotals];
120
121 // createHook() has already enforced that the callbacks are all functions,
122 // so here simply increment the count of whether each callbacks exists or
123 // not.
124 hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol];
125 hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol];
126 hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol];
127 hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol];
128 hook_fields[kTotals] +=
129 hook_fields[kPromiseResolve] += +!!this[promise_resolve_symbol];
130 ArrayPrototypePush(hooks_array, this);
131
132 if (prev_kTotals === 0 && hook_fields[kTotals] > 0) {
133 enableHooks();
134 }
135
136 if (!this[kNoPromiseHook]) {
137 updatePromiseHookMode();
138 }
139
140 return this;
141 }
142
143 disable() {
144 const { 0: hooks_array, 1: hook_fields } = getHookArrays();

Callers

nothing calls this directly

Calls 3

getHookArraysFunction · 0.85
enableHooksFunction · 0.85
updatePromiseHookModeFunction · 0.85

Tested by

no test coverage detected