MCPcopy
hub / github.com/frappe/erpnext / format

Function format

banking/src/lib/translate.ts:27–44  ·  view source on GitHub ↗
(str: string, args: string[])

Source from the content-addressed store, hash-verified

25};
26
27function format(str: string, args: string[]) {
28 if (str == undefined) return str;
29
30 let unkeyed_index = 0;
31 return str.replace(
32 /\{(\w*)\}/g,
33 function (match, key) {
34 if (key === "") {
35 key = unkeyed_index;
36 unkeyed_index++;
37 }
38 if (key == +key) {
39 return args[key] ?? match;
40 }
41 return ""
42 }
43 );
44}
45export default _;

Callers 1

_Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected