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

Function insertAtLineAtIndex

tools/js/utils/insert-at-line.js:28–37  ·  view source on GitHub ↗
(oldContents, index, content)

Source from the content-addressed store, hash-verified

26}
27
28const insertAtLineAtIndex = (oldContents, index, content) => {
29 const line = getLineNumberOfIndex(oldContents, index)
30 const lines = oldContents.split('\n')
31 lines.splice(line, 0, content)
32
33 return `${lines
34 .join('\n')
35 .replace(/\n{3,}/g, '\n\n')
36 .replace(/\n*$/, '')}`
37}
38
39export { insertAtLineAtIndex }

Callers 1

mainFunction · 0.90

Calls 4

getLineNumberOfIndexFunction · 0.85
replaceMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected