MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / protect

Function protect

src/runtime/adapters/markdown.ts:26–40  ·  view source on GitHub ↗
(
  text: string,
  pattern: RegExp,
  placeholders: string[],
  render: (match: string, ...groups: string[]) => string,
)

Source from the content-addressed store, hash-verified

24}
25
26function protect(
27 text: string,
28 pattern: RegExp,
29 placeholders: string[],
30 render: (match: string, ...groups: string[]) => string,
31): string {
32 const nextText = text.replace(pattern, (...args) => {
33 const match = args[0] as string;
34 const groups = args.slice(1, -2) as string[];
35 const token = `${PLACEHOLDER_START}${placeholders.length}${PLACEHOLDER_END}`;
36 placeholders.push(render(match, ...groups));
37 return token;
38 });
39 return nextText;
40}
41
42function restore(text: string, placeholders: string[]): string {
43 return text.replace(

Callers 2

formatSlackMessageFunction · 0.85
formatTelegramMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected