MCPcopy
hub / github.com/postcss/postcss / positionBy

Method positionBy

lib/node.js:211–232  ·  view source on GitHub ↗
(opts = {})

Source from the content-addressed store, hash-verified

209 }
210
211 positionBy(opts = {}) {
212 let inputString =
213 'document' in this.source.input
214 ? this.source.input.document
215 : this.source.input.css
216 let pos = {
217 column: this.source.start.column,
218 line: this.source.start.line,
219 offset: sourceOffset(inputString, this.source.start)
220 }
221 if (opts.index) {
222 pos = this.positionInside(opts.index)
223 } else if (opts.word) {
224 let stringRepresentation = inputString.slice(
225 sourceOffset(inputString, this.source.start),
226 sourceOffset(inputString, this.source.end)
227 )
228 let index = stringRepresentation.indexOf(opts.word)
229 if (index !== -1) pos = this.positionInside(index)
230 }
231 return pos
232 }
233
234 positionInside(index) {
235 let column = this.source.start.column

Callers 1

node.test.tsFile · 0.80

Calls 2

positionInsideMethod · 0.95
sourceOffsetFunction · 0.85

Tested by

no test coverage detected