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 e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d["to-key-path.ts"] ef204000_8998_5a6c_5455_324b37624713["segment.ts"] e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d --> ef204000_8998_5a6c_5455_324b37624713 f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment"] e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d --> f712ed47_45d4_4e5a_dd73_fdefa1da71da 4ccbfbad_b80c_422a_38fe_dc35ee118e8d["migrate-preflight.ts"] 4ccbfbad_b80c_422a_38fe_dc35ee118e8d --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d de8dd9be_8c47_4694_db3b_393c549a926a["migrate-theme-to-var.ts"] de8dd9be_8c47_4694_db3b_393c549a926a --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e["canonicalize-candidates.ts"] 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d af1a6ece_0432_a556_fd63_8cb4a91f12ad["plugin-api.ts"] af1a6ece_0432_a556_fd63_8cb4a91f12ad --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d 20b59de8_11c6_2432_2a83_24f6f6e741a7["plugin-functions.ts"] 20b59de8_11c6_2432_2a83_24f6f6e741a7 --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d 0cb00ce0_5f54_8628_99aa_0c832deb2600["to-key-path.bench.ts"] 0cb00ce0_5f54_8628_99aa_0c832deb2600 --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d 1f67cad2_89b7_73d4_1d18_ba4272a72fae["to-key-path.test.ts"] 1f67cad2_89b7_73d4_1d18_ba4272a72fae --> e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d style e3e0c6b9_7cc3_bd6c_ce01_14f8efdc5a0d 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 OxideEngine domain, PreProcessors 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: OxideEngine, subdomain: PreProcessors, 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