@@ -3,13 +3,14 @@ import AsyncLimiterClass, {
3
3
AsyncCurrentLimiter ,
4
4
} from "https://cdn.skypack.dev/@masx200/[email protected] ?dts" ;
5
5
import { WalkEntry } from "https://deno.land/[email protected] /fs/_util.ts" ;
6
+ import { group } from "./deps.ts" ;
6
7
function searchFilesNames ( {
7
8
skip,
8
9
} : // limiter,
9
- {
10
- skip ?: RegExp | RegExp [ ] ;
11
- // limiter: AsyncCurrentLimiter;
12
- } ) {
10
+ {
11
+ skip ?: RegExp | RegExp [ ] ;
12
+ // limiter: AsyncCurrentLimiter;
13
+ } ) {
13
14
console . log ( "type check start!" ) ;
14
15
15
16
const entry_iter = walk ( "." , {
@@ -27,35 +28,32 @@ if (import.meta.main) {
27
28
28
29
async function parallel_check (
29
30
entry_iter : AsyncIterableIterator < WalkEntry > ,
30
- limiter : AsyncCurrentLimiter
31
+ limiter : AsyncCurrentLimiter ,
31
32
) {
32
- const stack : string [ ] = [ ] ;
33
+ const files : string [ ] = [ ] ;
33
34
34
- const ps : Array < Promise < void > > = [ ] ;
35
35
for await ( const entry of entry_iter ) {
36
- if ( stack . length < 15 ) {
37
- stack . push ( entry . path ) ;
38
- } else {
39
- ps . push ( limiter . run ( ( ) => runDenoCheck ( [ ...stack , entry . path ] ) ) ) ;
40
- stack . length = 0 ;
41
- }
36
+ files . push ( entry . path ) ;
42
37
}
43
- if ( stack . length ) {
44
- ps . push ( limiter . run ( ( ) => runDenoCheck ( stack ) ) ) ;
45
- }
46
- await Promise . all ( ps ) ;
38
+
39
+ const entries = Object . values (
40
+ group ( files , ( _s : any , i : number ) => i % 50 ) ,
41
+ ) as string [ ] [ ] ;
42
+
43
+ await Promise . all (
44
+ entries . map ( ( stack ) => limiter . run ( ( ) => runDenoCheck ( stack ) ) ) ,
45
+ ) ;
47
46
}
48
47
49
48
async function start ( ) {
50
49
const limiter = new AsyncLimiterClass ( navigator . hardwareConcurrency ) ;
51
50
const args = parse ( Deno . args ) ;
52
51
console . log ( args ) ;
53
- const skip =
54
- typeof args . skip === "string"
55
- ? new RegExp ( String ( args . skip ) )
56
- : Array . isArray ( args . skip )
57
- ? args . skip . map ( ( s ) => new RegExp ( s ) )
58
- : undefined ;
52
+ const skip = typeof args . skip === "string"
53
+ ? new RegExp ( String ( args . skip ) )
54
+ : Array . isArray ( args . skip )
55
+ ? args . skip . map ( ( s ) => new RegExp ( s ) )
56
+ : undefined ;
59
57
const entry_iter = searchFilesNames ( { skip } ) ;
60
58
await parallel_check ( entry_iter , limiter ) ;
61
59
console . log ( "type check Done!" ) ;
0 commit comments