multisplice
easily splice a string multiple times, using offsets into the original string
Install
npm install multisplice
Usage
Renaming identifiers in Javascript code:
var multisplice = var dedent = var astw = var src = dedent` function beep (boop) { boop *= baz console.log(boop) } var baz = 10 beep(17)` var splicer = var renames = {}var nextName = 'a' { if nodetype === 'Identifier' if !renamesnodename renamesnodename = String splicer } console
function a (b) {
b *= c
d.e(b)
}
var c = 10
a(17)
API
var s = multisplice(string)
Create a string splicer instance. This instance will splice things into string
.
s.splice(start, end, value)
Replace the slice from indices start
to end
in the original string with value
.
s.slice(start, end)
Get a part of the spliced string, using indices start
to end
from the original string.
s.toString()
Get the full spliced string (.slice(0)
).