MCPcopy
hub / github.com/tailwindlabs/tailwindcss / walk

Function walk

packages/@tailwindcss-upgrade/src/utils/walk.ts:18–37  ·  view source on GitHub ↗
(
  rule: Walkable<T>,
  cb: (rule: T, idx: number, parent: Walkable<T>) => void | WalkAction,
)

Source from the content-addressed store, hash-verified

16// Custom walk implementation where we can skip going into nodes when we don't
17// need to process them.
18export function walk<T>(
19 rule: Walkable<T>,
20 cb: (rule: T, idx: number, parent: Walkable<T>) => void | WalkAction,
21): undefined | false {
22 let result: undefined | false = undefined
23
24 rule.each?.((node, idx) => {
25 let action = cb(node, idx, rule) ?? WalkAction.Continue
26 if (action === WalkAction.Stop) {
27 result = false
28 return result
29 }
30 if (action !== WalkAction.Skip) {
31 result = walk(node as Walkable<T>, cb)
32 return result
33 }
34 })
35
36 return result
37}
38
39// Depth first walk reversal implementation.
40export function walkDepth<T>(rule: Walkable<T>, cb: (rule: T) => void) {

Callers 11

rewriteUrlsFunction · 0.90
splitFunction · 0.90
migrateFunction · 0.90
migrateFunction · 0.90
migrateAtLayerUtilitiesFunction · 0.90
migrateFunction · 0.90
getAppliedNodeStackFunction · 0.90
convertFunction · 0.90

Calls 1

eachMethod · 0.80

Tested by

no test coverage detected