to-key-path.ts — tailwindcss Source File
Architecture documentation for to-key-path.ts, a typescript file in the tailwindcss codebase. 2 imports, 7 dependents.
Entity Profile
Dependency Diagram
graph LR 1f643124_89df_1d95_f8fd_e4036c7301de["to-key-path.ts"] bb9924cc_8308_a1f9_0e30_76de45a64970["segment.ts"] 1f643124_89df_1d95_f8fd_e4036c7301de --> bb9924cc_8308_a1f9_0e30_76de45a64970 c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment"] 1f643124_89df_1d95_f8fd_e4036c7301de --> c58cbb33_f3cc_0b4f_844a_15bf66a1dc61 f67a6019_88a0_ffd1_f91c_1a51645f6931["migrate-preflight.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 1f643124_89df_1d95_f8fd_e4036c7301de c36efdeb_7fd2_0935_2c28_bf15095a9dd9["migrate-theme-to-var.ts"] c36efdeb_7fd2_0935_2c28_bf15095a9dd9 --> 1f643124_89df_1d95_f8fd_e4036c7301de f6c14bbb_2e42_58cc_18f1_c89a243da9c0["canonicalize-candidates.ts"] f6c14bbb_2e42_58cc_18f1_c89a243da9c0 --> 1f643124_89df_1d95_f8fd_e4036c7301de da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"] da5d1116_ab2a_437a_6b13_c1429fd546fa --> 1f643124_89df_1d95_f8fd_e4036c7301de 3d2f062b_d3ec_6b3a_dc32_9d2e4732e20e["plugin-functions.ts"] 3d2f062b_d3ec_6b3a_dc32_9d2e4732e20e --> 1f643124_89df_1d95_f8fd_e4036c7301de 911b650c_d689_882c_d7b6_1fe3a2de3359["to-key-path.bench.ts"] 911b650c_d689_882c_d7b6_1fe3a2de3359 --> 1f643124_89df_1d95_f8fd_e4036c7301de 33590675_cf8c_f667_c3ed_0c404ca18489["to-key-path.test.ts"] 33590675_cf8c_f667_c3ed_0c404ca18489 --> 1f643124_89df_1d95_f8fd_e4036c7301de style 1f643124_89df_1d95_f8fd_e4036c7301de fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { segment } from './segment'
/**
* Parse a path string into an array of path segments
*
* Square bracket notation `a[b]` may be used to "escape" dots that would
* otherwise be interpreted as path separators.
*
* Example:
* a -> ['a']
* a.b.c -> ['a', 'b', 'c']
* a[b].c -> ['a', 'b', 'c']
* a[b.c].e.f -> ['a', 'b.c', 'e', 'f']
* a[b][c][d] -> ['a', 'b', 'c', 'd']
*
* @param {string} path
**/
export function toKeyPath(path: string) {
let keypath: string[] = []
for (let part of segment(path, '.')) {
if (!part.includes('[')) {
keypath.push(part)
continue
}
let currentIndex = 0
while (true) {
let bracketL = part.indexOf('[', currentIndex)
let bracketR = part.indexOf(']', bracketL)
if (bracketL === -1 || bracketR === -1) {
break
}
// Add the part before the bracket as a key
if (bracketL > currentIndex) {
keypath.push(part.slice(currentIndex, bracketL))
}
// Add the part inside the bracket as a key
keypath.push(part.slice(bracketL + 1, bracketR))
currentIndex = bracketR + 1
}
// Add the part after the last bracket as a key
if (currentIndex <= part.length - 1) {
keypath.push(part.slice(currentIndex))
}
}
return keypath
}
Domain
Subdomains
Functions
Dependencies
Imported By
- packages/tailwindcss/src/canonicalize-candidates.ts
- packages/@tailwindcss-upgrade/src/codemods/css/migrate-preflight.ts
- packages/@tailwindcss-upgrade/src/codemods/template/migrate-theme-to-var.ts
- packages/tailwindcss/src/compat/plugin-api.ts
- packages/tailwindcss/src/compat/plugin-functions.ts
- packages/tailwindcss/src/utils/to-key-path.bench.ts
- packages/tailwindcss/src/utils/to-key-path.test.ts
Source
Frequently Asked Questions
What does to-key-path.ts do?
to-key-path.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain, Extractor subdomain.
What functions are defined in to-key-path.ts?
to-key-path.ts defines 1 function(s): toKeyPath.
What does to-key-path.ts depend on?
to-key-path.ts imports 2 module(s): segment, segment.ts.
What files import to-key-path.ts?
to-key-path.ts is imported by 7 file(s): canonicalize-candidates.ts, migrate-preflight.ts, migrate-theme-to-var.ts, plugin-api.ts, plugin-functions.ts, to-key-path.bench.ts, to-key-path.test.ts.
Where is to-key-path.ts in the architecture?
to-key-path.ts is located at packages/tailwindcss/src/utils/to-key-path.ts (domain: Oxide, subdomain: Extractor, directory: packages/tailwindcss/src/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free