MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / getLineNumberOfIndex

Function getLineNumberOfIndex

tools/js/utils/insert-at-line.js:15–26  ·  view source on GitHub ↗
(data, index)

Source from the content-addressed store, hash-verified

13// limitations under the License.
14
15const getLineNumberOfIndex = (data, index) => {
16 const lines = data.split('\n')
17 let line = 0
18 let i = 0
19
20 while (i < index) {
21 i += lines[line].length + 1
22 line++
23 }
24
25 return line
26}
27
28const insertAtLineAtIndex = (oldContents, index, content) => {
29 const line = getLineNumberOfIndex(oldContents, index)

Callers 1

insertAtLineAtIndexFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected