MCPcopy Create free account
hub / github.com/formatjs/formatjs / extractExpression

Function extractExpression

packages/cli-lib/svelte_extractor.ts:35–52  ·  view source on GitHub ↗
(
  expression: SvelteNode | null | undefined,
  source: string,
  parseScriptFn: ScriptParseFn
)

Source from the content-addressed store, hash-verified

33}
34
35function extractExpression(
36 expression: SvelteNode | null | undefined,
37 source: string,
38 parseScriptFn: ScriptParseFn
39): void {
40 if (!expression || expression.start == null || expression.end == null) {
41 return
42 }
43 const content = source.slice(expression.start, expression.end)
44 try {
45 parseScriptFn(`(${content})`)
46 } catch (e) {
47 console.warn(
48 `Failed to parse "${content}". Ignore this if content has no extractable message`,
49 e
50 )
51 }
52}
53
54function getStringAttributeValue(value: SvelteNode): string {
55 return value.data ?? value.raw ?? ''

Callers 1

walkNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected