MCPcopy
hub / github.com/facebook/react / wrapperMethod

Function wrapperMethod

packages/react-server/src/ReactFlightServer.js:390–416  ·  view source on GitHub ↗
(this: typeof console)

Source from the content-addressed store, hash-verified

388 'name',
389 );
390 const wrapperMethod = function (this: typeof console) {
391 const request = resolveRequest();
392 if (methodName === 'assert' && arguments[0]) {
393 // assert doesn't emit anything unless first argument is falsy so we can skip it.
394 } else if (request !== null) {
395 // Extract the stack. Not all console logs print the full stack but they have at
396 // least the line it was called from. We could optimize transfer by keeping just
397 // one stack frame but keeping it simple for now and include all frames.
398 const stack = filterStackTrace(
399 request,
400 parseStackTracePrivate(new Error('react-stack-top-frame'), 1) || [],
401 );
402 request.pendingDebugChunks++;
403 const owner: null | ReactComponentInfo = resolveOwner();
404 const args = Array.from(arguments);
405 // Extract the env if this is a console log that was replayed from another env.
406 let env = unbadgeConsole(methodName, args);
407 if (env === null) {
408 // Otherwise add the current environment.
409 env = (0, request.environmentName)();
410 }
411
412 emitConsoleChunk(request, methodName, owner, env, stack, args);
413 }
414 // $FlowFixMe[incompatible-call]
415 return originalMethod.apply(this, arguments);
416 };
417 if (originalName) {
418 Object.defineProperty(
419 wrapperMethod,

Callers

nothing calls this directly

Calls 7

resolveOwnerFunction · 0.90
filterStackTraceFunction · 0.85
parseStackTracePrivateFunction · 0.85
emitConsoleChunkFunction · 0.85
resolveRequestFunction · 0.70
unbadgeConsoleFunction · 0.70
applyMethod · 0.45

Tested by

no test coverage detected