MCPcopy
hub / github.com/postcss/postcss / sourceOffset

Function sourceOffset

lib/node.js:35–60  ·  view source on GitHub ↗
(inputCSS, position)

Source from the content-addressed store, hash-verified

33}
34
35function sourceOffset(inputCSS, position) {
36 // Not all custom syntaxes support `offset` in `source.start` and `source.end`
37 if (position && typeof position.offset !== 'undefined') {
38 return position.offset
39 }
40
41 let column = 1
42 let line = 1
43 let offset = 0
44
45 for (let i = 0; i < inputCSS.length; i++) {
46 if (line === position.line && column === position.column) {
47 offset = i
48 break
49 }
50
51 if (inputCSS[i] === '\n') {
52 column = 1
53 line += 1
54 } else {
55 column += 1
56 }
57 }
58
59 return offset
60}
61
62class Node {
63 get proxyOf() {

Callers 3

positionByMethod · 0.85
positionInsideMethod · 0.85
rangeByMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…