MCPcopy
hub / github.com/browserslist/browserslist / eachParent

Function eachParent

node.js:72–103  ·  view source on GitHub ↗
(file, callback, cache)

Source from the content-addressed store, hash-verified

70}
71
72function eachParent(file, callback, cache) {
73 var loc = path.resolve(file)
74 var pathsForCacheResult = []
75 var result
76 do {
77 if (!pathInRoot(loc)) {
78 break
79 }
80 if (cache && loc in cache) {
81 result = cache[loc]
82 break
83 }
84 pathsForCacheResult.push(loc)
85
86 if (!isDirectory(loc)) {
87 continue
88 }
89
90 var locResult = callback(loc)
91 if (typeof locResult !== 'undefined') {
92 result = locResult
93 break
94 }
95 } while (loc !== (loc = path.dirname(loc)))
96
97 if (cache && !process.env.BROWSERSLIST_DISABLE_CACHE) {
98 pathsForCacheResult.forEach(function (cachePath) {
99 cache[cachePath] = result
100 })
101 }
102 return result
103}
104
105function pathInRoot(p) {
106 if (!process.env.BROWSERSLIST_ROOT_PATH) return true

Callers 1

node.jsFile · 0.85

Calls 2

pathInRootFunction · 0.85
isDirectoryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…