* Prefixes substrings within the given strings. * * @private * @param {String} prefix - A prefix. * @param {Iterable } substrings - The substrings. * @param {Map } strings - A collection of named strings.
(prefix, substrings, strings)
| 17 | */ |
| 18 | |
| 19 | function prefixSubstrings(prefix, substrings, strings) { |
| 20 | |
| 21 | for(const substring of substrings) { |
| 22 | |
| 23 | // Prefix the substring and build a RegExp that searches for the unprefixed version. |
| 24 | const prefixed = "$1" + prefix + substring.charAt(0).toUpperCase() + substring.slice(1); |
| 25 | const regExp = new RegExp("([^\\.])(\\b" + substring + "\\b)", "g"); |
| 26 | |
| 27 | for(const entry of strings.entries()) { |
| 28 | |
| 29 | if(entry[1] !== null) { |
| 30 | |
| 31 | // Replace all occurances of the substring with the prefixed version. |
| 32 | strings.set(entry[0], entry[1].replace(regExp, prefixed)); |
| 33 | |
| 34 | } |
| 35 | |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Integrates the given effect. |
no test coverage detected
searching dependent graphs…