function replacer()

in packages/x-flow/src/utils/index.ts [249:274]


  function replacer(key, value) {
    // 循环引用
    if (typeof value === 'object' && value !== null) {
      if (seen.has(value)) {
        return '[Circular]';
      }
      seen.add(value);
    }

    // React
    if (value && typeof value === 'object' && value._owner) {
      return '[React Element]';
    }

    // BigInt
    if (typeof value === 'bigint') {
      return value.toString();
    }

    // 其他无法序列化的类型
    if (typeof value === 'function') {
      return `[Function: ${value.name || 'anonymous'}]`;
    }

    return value;
  }