Home / Function/ mapPatternOperands() — react Function Reference

mapPatternOperands() — react Function Reference

Architecture documentation for the mapPatternOperands() function in visitors.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  f6e40907_93a0_cbc4_14eb_4d0ec248c01a["mapPatternOperands()"]
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  f6e40907_93a0_cbc4_14eb_4d0ec248c01a -->|defined in| 2f3caf55_cc64_415c_55dd_9771ba7dc210
  4f38d1cb_5a1e_1f03_9dbd_2513b7bb5a80["mapInstructionLValues()"]
  4f38d1cb_5a1e_1f03_9dbd_2513b7bb5a80 -->|calls| f6e40907_93a0_cbc4_14eb_4d0ec248c01a
  fb7d5dbf_1b8e_624d_5b62_7b7a22eeb272["transformDestructuring()"]
  fb7d5dbf_1b8e_624d_5b62_7b7a22eeb272 -->|calls| f6e40907_93a0_cbc4_14eb_4d0ec248c01a
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  f6e40907_93a0_cbc4_14eb_4d0ec248c01a -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  style f6e40907_93a0_cbc4_14eb_4d0ec248c01a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts lines 674–705

export function mapPatternOperands(
  pattern: Pattern,
  fn: (place: Place) => Place,
): void {
  switch (pattern.kind) {
    case 'ArrayPattern': {
      pattern.items = pattern.items.map(item => {
        if (item.kind === 'Identifier') {
          return fn(item);
        } else if (item.kind === 'Spread') {
          item.place = fn(item.place);
          return item;
        } else {
          return item;
        }
      });
      break;
    }
    case 'ObjectPattern': {
      for (const property of pattern.properties) {
        property.place = fn(property.place);
      }
      break;
    }
    default: {
      assertExhaustive(
        pattern,
        `Unexpected pattern kind \`${(pattern as any).kind}\``,
      );
    }
  }
}

Subdomains

Frequently Asked Questions

What does mapPatternOperands() do?
mapPatternOperands() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts.
Where is mapPatternOperands() defined?
mapPatternOperands() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts at line 674.
What does mapPatternOperands() call?
mapPatternOperands() calls 1 function(s): assertExhaustive.
What calls mapPatternOperands()?
mapPatternOperands() is called by 2 function(s): mapInstructionLValues, transformDestructuring.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free