MCPcopy Create free account
hub / github.com/pmndrs/postprocessing / prefixSubstrings

Function prefixSubstrings

src/passes/EffectPass.js:19–40  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

17 */
18
19function 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.

Callers 1

integrateEffectFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…