Skip to content

Commit a75cd1e

Browse files
committed
split_by_count.ts
1 parent 5bf34f8 commit a75cd1e

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

check.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { split_by_count } from "./utils/split_by_count.ts";
77
function searchFilesNames({
88
skip,
99
}: // limiter,
10-
{
11-
skip?: RegExp | RegExp[];
12-
// limiter: AsyncCurrentLimiter;
13-
}) {
10+
{
11+
skip?: RegExp | RegExp[];
12+
// limiter: AsyncCurrentLimiter;
13+
}) {
1414
console.log("type check start!");
1515

1616
const entry_iter = walk(".", {
@@ -28,7 +28,7 @@ if (import.meta.main) {
2828

2929
async function parallel_check(
3030
entry_iter: AsyncIterableIterator<WalkEntry>,
31-
limiter: AsyncCurrentLimiter
31+
limiter: AsyncCurrentLimiter,
3232
) {
3333
const files: string[] = [];
3434

@@ -39,19 +39,18 @@ async function parallel_check(
3939
const entries = split_by_count(files, 30);
4040

4141
await Promise.all(
42-
entries.map((stack) => limiter.run(() => runDenoCheck(stack)))
42+
entries.map((stack) => limiter.run(() => runDenoCheck(stack))),
4343
);
4444
}
4545
async function start() {
4646
const limiter = new AsyncLimiterClass(navigator.hardwareConcurrency);
4747
const args = parse(Deno.args);
4848
console.log(args);
49-
const skip =
50-
typeof args.skip === "string"
51-
? new RegExp(String(args.skip))
52-
: Array.isArray(args.skip)
53-
? args.skip.map((s) => new RegExp(s))
54-
: undefined;
49+
const skip = typeof args.skip === "string"
50+
? new RegExp(String(args.skip))
51+
: Array.isArray(args.skip)
52+
? args.skip.map((s) => new RegExp(s))
53+
: undefined;
5554
const entry_iter = searchFilesNames({ skip });
5655
await parallel_check(entry_iter, limiter);
5756
console.log("type check Done!");

utils/split_by_count.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { group } from "../deps.ts";
2-
3-
export function split_by_count<T>(files: T[], limit: number) {
4-
return Object.values(
5-
group(
6-
files,
7-
(_s: any, i: number) => i % Math.floor(files.length / limit)
8-
)
9-
) as T[][];
10-
}
1+
import { group } from "../deps.ts";
2+
3+
export function split_by_count<T>(files: T[], limit: number) {
4+
return Object.values(
5+
group(
6+
files,
7+
(_s: any, i: number) => i % Math.floor(files.length / limit),
8+
),
9+
) as T[][];
10+
}

0 commit comments

Comments
 (0)