MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isJavaScriptBlock

Function isJavaScriptBlock

src/extraction/sfc-script.ts:102–109  ·  view source on GitHub ↗
(attrs: string)

Source from the content-addressed store, hash-verified

100 * `importmap`, a `text/template`), which no script grammar reads.
101 */
102export function isJavaScriptBlock(attrs: string): boolean {
103 // `type`, not `data-type`; and the type itself, not its `; charset=…`.
104 const type = /(?:^|\s)type\s*=\s*["']([^"']*)["']/i.exec(attrs)?.[1]?.split(';')[0]!.trim().toLowerCase();
105 if (type === undefined || type === '') return true;
106 // A browser's (`module`, `text/javascript`), a build step's (`text/babel`,
107 // svelte-preprocess's bare `ts`), and Partytown's, which runs it in a worker.
108 return /^(?:module|(?:(?:text|application)\/)?(?:x-)?(?:javascript|ecmascript|typescript|babel|jsx|tsx|js|ts)|text\/partytown)$/.test(type);
109}
110
111/** The hosts whose markup {@link sfcMarkupElements} reads. */
112export type SfcMarkupHost = 'svelte' | 'astro';

Callers 5

extractScriptBlocksMethod · 0.90
extractScriptBlocksMethod · 0.90
syntaxRegionsForFunction · 0.90
processScriptBlocksMethod · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected