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

Function emitChunk

packages/react-server/src/ReactFlightServer.js:5493–5579  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  value: ReactClientValue,
)

Source from the content-addressed store, hash-verified

5491}
5492
5493function emitChunk(
5494 request: Request,
5495 task: Task,
5496 value: ReactClientValue,
5497): void {
5498 const id = task.id;
5499 // For certain types we have special types, we typically outlined them but
5500 // we can emit them directly for this row instead of through an indirection.
5501 if (typeof value === 'string' && byteLengthOfChunk !== null) {
5502 if (enableTaint) {
5503 const tainted = TaintRegistryValues.get(value);
5504 if (tainted !== undefined) {
5505 throwTaintViolation(tainted.message);
5506 }
5507 }
5508 emitTextChunk(request, id, value, false);
5509 return;
5510 }
5511 if (value instanceof ArrayBuffer) {
5512 emitTypedArrayChunk(request, id, 'A', new Uint8Array(value), false);
5513 return;
5514 }
5515 if (value instanceof Int8Array) {
5516 // char
5517 emitTypedArrayChunk(request, id, 'O', value, false);
5518 return;
5519 }
5520 if (value instanceof Uint8Array) {
5521 // unsigned char
5522 emitTypedArrayChunk(request, id, 'o', value, false);
5523 return;
5524 }
5525 if (value instanceof Uint8ClampedArray) {
5526 // unsigned clamped char
5527 emitTypedArrayChunk(request, id, 'U', value, false);
5528 return;
5529 }
5530 if (value instanceof Int16Array) {
5531 // sort
5532 emitTypedArrayChunk(request, id, 'S', value, false);
5533 return;
5534 }
5535 if (value instanceof Uint16Array) {
5536 // unsigned short
5537 emitTypedArrayChunk(request, id, 's', value, false);
5538 return;
5539 }
5540 if (value instanceof Int32Array) {
5541 // long
5542 emitTypedArrayChunk(request, id, 'L', value, false);
5543 return;
5544 }
5545 if (value instanceof Uint32Array) {
5546 // unsigned long
5547 emitTypedArrayChunk(request, id, 'l', value, false);
5548 return;
5549 }
5550 if (value instanceof Float32Array) {

Callers 2

retryTaskFunction · 0.85
tryStreamTaskFunction · 0.85

Calls 6

throwTaintViolationFunction · 0.85
emitTextChunkFunction · 0.85
emitTypedArrayChunkFunction · 0.85
stringifyFunction · 0.85
emitModelChunkFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected