MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / replacer

Function replacer

test/MagicString.test.ts:2094–2097  ·  view source on GitHub ↗
(match: string, p1: string, p2: string, p3: string, offset: number, string: string, groups: Record<string, string> | undefined)

Source from the content-addressed store, hash-verified

2092 it('replace function offset', () => {
2093 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_a_parameter
2094 function replacer(match: string, p1: string, p2: string, p3: string, offset: number, string: string, groups: Record<string, string> | undefined) {
2095 // p1 is nondigits, p2 digits, and p3 non-alphanumerics
2096 return [match, p1, p2, p3, offset, string, groups].join(' - ')
2097 }
2098 const code = 'abc12345#$*%'
2099 const regex = /(\D*)(\d*)(\W*)/
2100 assert.strictEqual(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected