INNER CODE UNIT · TypeScript

normalizePath

margelo/react-native-runtimes · packages/state/src/index.ts:264

function normalizePath(path: SharedStorePath): string[] {
  if (typeof path === 'string' && path === ROOT_SUBTREE_KEY) {
    return [];
  }

  const segments =
    typeof path === 'string'
      ? path.split('.')
      : path.map(segment => String(segment));
  const normalized = segments
    .map(segment => segment.trim())
    .filter(segment => segment.length > 0);

  if (normalized.length === 0) {
    throw new Error('Shared store paths must contain at least one segment');
  }

  return normalized;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…