File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import type { BlogRelease } from './package-registry.ts'
77import { htmlToMarkdown } from 'mdream'
8+ import pLimit from 'p-limit'
89import { yamlEscape } from '../core/yaml.ts'
910import { getBlogPreset } from './package-registry.ts'
1011import { compareSemver , parseSemver } from './releases.ts'
@@ -114,18 +115,12 @@ export async function fetchBlogReleases(
114115 if ( filteredReleases . length === 0 )
115116 return [ ]
116117
117- const releases : BlogReleasePost [ ] = [ ]
118-
119- // Fetch all blog posts in parallel with 3 concurrent requests
120- const batchSize = 3
121- for ( let i = 0 ; i < filteredReleases . length ; i += batchSize ) {
122- const batch = filteredReleases . slice ( i , i + batchSize )
123- const results = await Promise . all ( batch . map ( entry => fetchBlogPost ( entry ) ) )
124- for ( const result of results ) {
125- if ( result )
126- releases . push ( result )
127- }
128- }
118+ // Fetch all blog posts with controlled concurrency
119+ const limit = pLimit ( 3 )
120+ const results = await Promise . all (
121+ filteredReleases . map ( entry => limit ( ( ) => fetchBlogPost ( entry ) ) ) ,
122+ )
123+ const releases = results . filter ( ( r ) : r is BlogReleasePost => r !== null )
129124
130125 if ( releases . length === 0 )
131126 return [ ]
You can’t perform that action at this time.
0 commit comments