MCPcopy Create free account
hub / github.com/Lobos/react-ui / substitute

Function substitute

src/utils/strings.js:18–29  ·  view source on GitHub ↗
(str, obj)

Source from the content-addressed store, hash-verified

16}
17
18export function substitute(str, obj) {
19 if (typeof str === 'string') {
20 return str.replace((/\\?\{([^{}]+)\}/g), function(match, name){
21 if (match.charAt(0) === '\\') {
22 return match.slice(1);
23 }
24 return (obj[name] === null || obj[name] === undefined) ? '' : obj[name];
25 });
26 } else if (typeof str === 'function') {
27 return str(obj);
28 }
29}
30
31export function toArray(value, sep) {
32 if (value === null || value === undefined) {

Callers 4

formatDataFunction · 0.90
renderBodyMethod · 0.90
toTextValueFunction · 0.90
setTplFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…