MCPcopy Create free account
hub / github.com/chakra-ui/panda / splitBy

Function splitBy

packages/shared/src/split.ts:1–20  ·  view source on GitHub ↗
(value: string, separator = ',')

Source from the content-addressed store, hash-verified

1export function splitBy(value: string, separator = ',') {
2 const result: any[] = []
3 let current = ''
4 let depth = 0
5 for (let i = 0; i < value.length; i++) {
6 const char = value[i]
7 if (char === '(') {
8 depth++
9 } else if (char === ')') {
10 depth--
11 } else if (char === separator && depth === 0) {
12 result.push(current)
13 current = ''
14 continue
15 }
16 current += char
17 }
18 result.push(current)
19 return result
20}
21
22export function splitDotPath(path: string): string[] {
23 return path.split('.').reduce((acc, curr) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected