MCPcopy Index your code
hub / github.com/formatjs/formatjs / transformFn

Function transformFn

packages/ts-transformer/transform.ts:967–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965 const transformFn: typescript.TransformerFactory<
966 typescript.SourceFile
967 > = ctx => {
968 return sf => {
969 const pragmaResult = PRAGMA_REGEX.exec(sf.text)
970 if (pragmaResult) {
971 debug('Pragma found', pragmaResult)
972 const [, pragma, kvString] = pragmaResult
973 if (pragma === opts.pragma) {
974 const kvs = kvString.split(' ')
975 const result: Record<string, string> = {}
976 for (const kv of kvs) {
977 const [k, v] = kv.split(':')
978 result[k] = v
979 }
980 debug('Pragma extracted', result)
981 if (typeof opts.onMetaExtracted === 'function') {
982 opts.onMetaExtracted(sf.fileName, result)
983 }
984 }
985 }
986 return ts.visitEachChild(sf, getVisitor(ts, ctx, sf, opts), ctx)
987 }
988 }
989
990 return transformFn
991}

Callers

nothing calls this directly

Calls 2

getVisitorFunction · 0.85
debugFunction · 0.70

Tested by

no test coverage detected