MCPcopy Create free account
hub / github.com/Effect-TS/effect / extract

Function extract

packages/tools/doctest/src/Source.ts:83–92  ·  view source on GitHub ↗
(source: string, format: SourceFormat = "jsdoc")

Source from the content-addressed store, hash-verified

81 * @since 4.0.0
82 */
83export const extract = (source: string, format: SourceFormat = "jsdoc"): ReadonlyArray<Snippet> => {
84 if (!source.includes(runnableMarker)) {
85 return []
86 }
87
88 const lineAt = lineNumberAt(source)
89 return format === "markdown"
90 ? snippets(source, 0, lineAt)
91 : Array.from(source.matchAll(jsdocPattern)).flatMap((match) => snippets(match[0], match.index ?? 0, lineAt, true))
92}
93
94/**
95 * Reads a file and extracts its marked code snippets.

Callers 1

extractFileFunction · 0.70

Calls 2

lineNumberAtFunction · 0.85
snippetsFunction · 0.85

Tested by

no test coverage detected