MCPcopy
hub / github.com/webpack/tapable / runIntercept

Method runIntercept

test/HookTester.test.js:1148–1262  ·  view source on GitHub ↗
(result, type)

Source from the content-addressed store, hash-verified

1146 }
1147
1148 async runIntercept(result, type) {
1149 {
1150 const hook = this.createHook(["a", "b", "c"], `${type}Intercepted`);
1151 hook.intercept({
1152 call: (a, b, c) => {
1153 result[`${type}InterceptedCall1`] = [a, b, c];
1154 },
1155
1156 done: () => {
1157 result[`${type}InterceptedDone1`] = true;
1158 },
1159
1160 result: (r) => {
1161 result[`${type}InterceptedResult1`] = r;
1162 },
1163
1164 error: (err) => {
1165 result[`${type}InterceptedError1`] = err;
1166 },
1167
1168 tap: (tap) => {
1169 result[`${type}InterceptedTap1`] = { ...tap, fn: tap.fn.length };
1170 }
1171 });
1172 hook.intercept({
1173 call: (a, b, c) => {
1174 result[`${type}InterceptedCall2`] = [a, b, c];
1175 },
1176
1177 done: () => {
1178 result[`${type}InterceptedDone2`] = true;
1179 },
1180
1181 result: (r) => {
1182 result[`${type}InterceptedResult2`] = r;
1183 },
1184
1185 error: (err) => {
1186 result[`${type}InterceptedError2`] = err;
1187 },
1188
1189 tap: (tap) => {
1190 if (!result[`${type}InterceptedTap2`]) {
1191 result[`${type}InterceptedTap2`] = { ...tap, fn: tap.fn.length };
1192 }
1193 }
1194 });
1195 hook.tap("sync", (a, b, c) => a + b + c);
1196 hook.tapPromise("promise", (a, b) => Promise.resolve(a + b + 1));
1197 result[`${type}Intercepted`] = await this.gainResult((cb) =>
1198 hook[type](1, 2, 3, cb)
1199 );
1200 }
1201
1202 {
1203 const hook = this.createHook(
1204 ["a", "b", "c"],
1205 `${type}ContextIntercepted`

Callers 1

runMethod · 0.95

Calls 5

createHookMethod · 0.95
gainResultMethod · 0.95
interceptMethod · 0.45
tapMethod · 0.45
tapPromiseMethod · 0.45

Tested by

no test coverage detected