MCPcopy Create free account
hub / github.com/nodejs/node / #highlight

Method #highlight

deps/npm/lib/utils/format-search-stream.js:159–174  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

157 }
158
159 #highlight (input) {
160 let output = input
161 for (const arg of this.#args) {
162 let i = output.toLowerCase().indexOf(arg)
163 while (i > -1) {
164 const highlit = this.#chalk.cyan(output.slice(i, i + arg.length))
165 output = [
166 output.slice(0, i),
167 highlit,
168 output.slice(i + arg.length),
169 ].join('')
170 i = output.toLowerCase().indexOf(arg, i + highlit.length)
171 }
172 }
173 return output
174 }
175}

Callers 1

writeMethod · 0.95

Calls 3

sliceMethod · 0.65
indexOfMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected