MCPcopy Index your code
hub / github.com/github/docs / getSmartSplit

Function getSmartSplit

lib/get-data.js:208–226  ·  view source on GitHub ↗
(dottedPath)

Source from the content-addressed store, hash-verified

206}
207
208function getSmartSplit(dottedPath) {
209 const split = dottedPath.split('.')
210 const bits = []
211 for (let i = 0, len = split.length; i < len; i++) {
212 const bit = split[i]
213 if (i === len - 1) {
214 bits.push(bit)
215 } else {
216 const next = split[i + 1]
217 if (/\d$/.test(bit) && /^\d/.test(next)) {
218 bits.push([bit, next].join('.'))
219 i++ // jump ahead one position in the loop
220 } else {
221 bits.push(bit)
222 }
223 }
224 }
225 return bits
226}
227
228// The reason this is memoized, even though the parent caller function
229// (`getDataByLanguage`) is also memoized is because we might read

Callers 1

getDataByDirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected