@@ -164,9 +164,7 @@ function resolveGranularities(options: EcfrConvertOptions): EcfrGranularityOutpu
164164 const hasSingle = options . granularity !== undefined || options . output !== undefined ;
165165
166166 if ( hasMulti && hasSingle ) {
167- throw new Error (
168- "convertEcfrTitle: `granularities` is mutually exclusive with `granularity`/`output`" ,
169- ) ;
167+ throw new Error ( "convertEcfrTitle: `granularities` is mutually exclusive with `granularity`/`output`" ) ;
170168 }
171169
172170 if ( hasMulti ) {
@@ -177,9 +175,7 @@ function resolveGranularities(options: EcfrConvertOptions): EcfrGranularityOutpu
177175 const seen = new Set < EcfrGranularity > ( ) ;
178176 for ( const entry of list ) {
179177 if ( seen . has ( entry . granularity ) ) {
180- throw new Error (
181- `convertEcfrTitle: duplicate granularity "${ entry . granularity } " in \`granularities\`` ,
182- ) ;
178+ throw new Error ( `convertEcfrTitle: duplicate granularity "${ entry . granularity } " in \`granularities\`` ) ;
183179 }
184180 seen . add ( entry . granularity ) ;
185181 }
@@ -200,15 +196,9 @@ function resolveGranularities(options: EcfrConvertOptions): EcfrGranularityOutpu
200196 * - Single-granularity mode (`output` + optional `granularity`) returns one `EcfrConvertResult`.
201197 * - Multi-granularity mode (`granularities`) parses once and returns one result per entry.
202198 */
203- export async function convertEcfrTitle (
204- options : MultiEcfrConvertOptions ,
205- ) : Promise < EcfrConvertResult [ ] > ;
206- export async function convertEcfrTitle (
207- options : SingleEcfrConvertOptions ,
208- ) : Promise < EcfrConvertResult > ;
209- export async function convertEcfrTitle (
210- options : EcfrConvertOptions ,
211- ) : Promise < EcfrConvertResult | EcfrConvertResult [ ] > {
199+ export async function convertEcfrTitle ( options : MultiEcfrConvertOptions ) : Promise < EcfrConvertResult [ ] > ;
200+ export async function convertEcfrTitle ( options : SingleEcfrConvertOptions ) : Promise < EcfrConvertResult > ;
201+ export async function convertEcfrTitle ( options : EcfrConvertOptions ) : Promise < EcfrConvertResult | EcfrConvertResult [ ] > {
212202 const granularityList = resolveGranularities ( options ) ;
213203
214204 // Build the emit set as the union of levels needed across requested granularities.
@@ -303,7 +293,7 @@ function extractTitleInfo(collectedByLevel: Map<LevelType, CollectedSection[]>):
303293
304294 console . warn (
305295 "[@lexbuild/ecfr] convertEcfrTitle: could not resolve title number from emitted nodes; " +
306- " output will use `/us/cfr/t0/...` identifiers. Source XML likely missing a DIV1 TYPE=\ "TITLE\"." ,
296+ ' output will use `/us/cfr/t0/...` identifiers. Source XML likely missing a DIV1 TYPE="TITLE".' ,
307297 ) ;
308298 return { titleNumber : "0" , titleName : "" } ;
309299}
@@ -427,9 +417,7 @@ async function writeGranularity(args: WriteGranularityArgs): Promise<EcfrConvert
427417 ? files . length
428418 : granularity === "chapter"
429419 ? new Set (
430- collected
431- . map ( ( c ) => c . context . ancestors . find ( ( a ) => a . levelType === "part" ) ?. numValue )
432- . filter ( Boolean ) ,
420+ collected . map ( ( c ) => c . context . ancestors . find ( ( a ) => a . levelType === "part" ) ?. numValue ) . filter ( Boolean ) ,
433421 ) . size
434422 : 0 ;
435423
@@ -548,15 +536,7 @@ async function writeSectionGranularity(args: SectionWriteArgs): Promise<EcfrConv
548536 if ( currentRss > peakMemory ) peakMemory = currentRss ;
549537 }
550538
551- await writeMetaFiles (
552- sectionMetas ,
553- titleNumber ,
554- titleName ,
555- output ,
556- "section" ,
557- options . input ,
558- options . currencyDate ,
559- ) ;
539+ await writeMetaFiles ( sectionMetas , titleNumber , titleName , output , "section" , options . input , options . currencyDate ) ;
560540
561541 const files = sectionMetas . map ( ( m ) => join ( buildTitleDir ( titleNumber , output ) , m . relativeFile ) ) ;
562542
0 commit comments