MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / addLineAfterLastOccurrence

Function addLineAfterLastOccurrence

SurgeModuleTool.js:36–49  ·  view source on GitHub ↗
(text, addition)

Source from the content-addressed store, hash-verified

34}
35
36function addLineAfterLastOccurrence(text, addition) {
37 const regex = /^#!.+?$/gm
38 const matchArray = text.match(regex)
39 const lastIndex = matchArray ? matchArray.length - 1 : -1
40
41 if (lastIndex >= 0) {
42 const lastMatch = matchArray[lastIndex]
43 const insertIndex = text.indexOf(lastMatch) + lastMatch.length
44 const newText = text.slice(0, insertIndex) + addition + text.slice(insertIndex)
45 return newText
46 }
47
48 return text
49}
50
51let idx
52let fromUrlScheme

Callers 1

SurgeModuleTool.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected