farm-life
Prepend/append string X (or ensure string X is prepended/appended) to each occurrence of string Y in string Z
Install
$ npm install --save farm-life
Not using Node or a module bundler? Use a UMD build via the <script>
tag.
Usage
const haystack = '[]-$$the gr$$[]-eat gat$sby $$[]'const needle = '$$'const attachment = '[]-' // '[]-$$[]-the gr$$[]-[]-eat gat$sby $$[]-[]' // '[]-$$[]-the gr$$[]-eat gat$sby $$[]-[]' // []-[]-$$the gr[]-$$[]-eat gat$sby []-$$[] // '[]-$$the gr[]-$$[]-eat gat$sby []-$$[]'