{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "split-text",
  "title": "split text",
  "description": "split text utility function, allows to split text into characters, words, returns (characters, words, characterCount, wordCount).",
  "files": [
    {
      "path": "registry/utils/split-text/index.ts",
      "content": "interface SplitTextResult {\n  words: string[];\n  characters: string[];\n  wordCount: number;\n  characterCount: number;\n}\n\n/**\n * Splits text into words and characters while preserving spaces\n * @param text - The text to split\n * @returns Object containing words array, characters array, and counts\n * @example\n * const result = splitText(\"Hello World\");\n * // result = {\n * //   words: [\"Hello \", \"World \"],\n * //   characters: [\"H\", \"e\", \"l\", \"l\", \"o\", \" \", \"W\", \"o\", \"r\", \"l\", \"d\", \" \"],\n * //   wordCount: 2,\n * //   characterCount: 12\n * // }\n */\nexport function splitText(text: string): SplitTextResult {\n  // Handle empty or whitespace-only strings\n  if (!text?.trim()) {\n    return {\n      words: [],\n      characters: [],\n      wordCount: 0,\n      characterCount: 0,\n    };\n  }\n\n  // Split into words and preserve spaces\n  const words = text.split(' ').map((word) => word.concat(' '));\n\n  // Split into characters\n  const characters = words.map((word) => word.split('')).flat(1);\n\n  return {\n    words,\n    characters,\n    wordCount: words.length,\n    characterCount: characters.length,\n  };\n}\n",
      "type": "registry:lib",
      "target": "components/systaliko-ui/utils/split-text.ts"
    }
  ],
  "type": "registry:lib"
}