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

Function emitTextChunk

packages/react-server/src/ReactFlightServer.js:4537–4563  ·  view source on GitHub ↗
(
  request: Request,
  id: number,
  text: string,
  debug: boolean,
)

Source from the content-addressed store, hash-verified

4535}
4536
4537function emitTextChunk(
4538 request: Request,
4539 id: number,
4540 text: string,
4541 debug: boolean,
4542): void {
4543 if (byteLengthOfChunk === null) {
4544 // eslint-disable-next-line react-internal/prod-error-codes
4545 throw new Error(
4546 'Existence of byteLengthOfChunk should have already been checked. This is a bug in React.',
4547 );
4548 }
4549 if (debug) {
4550 request.pendingDebugChunks++;
4551 } else {
4552 request.pendingChunks++; // Extra chunk for the header.
4553 }
4554 const textChunk = stringToChunk(text);
4555 const binaryLength = byteLengthOfChunk(textChunk);
4556 const row = id.toString(16) + ':T' + binaryLength.toString(16) + ',';
4557 const headerChunk = stringToChunk(row);
4558 if (__DEV__ && debug) {
4559 request.completedDebugChunks.push(headerChunk, textChunk);
4560 } else {
4561 request.completedRegularChunks.push(headerChunk, textChunk);
4562 }
4563}
4564
4565function serializeEval(source: string): string {
4566 if (!__DEV__) {

Callers 3

serializeLargeTextStringFunction · 0.85
emitChunkFunction · 0.85

Calls 4

stringToChunkFunction · 0.90
byteLengthOfChunkFunction · 0.90
toStringMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected