Skip to content

Commit 902dbae

Browse files
committed
👍 Use Set#difference/intersection instead
1 parent f3cadc2 commit 902dbae

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

.scripts/gen-function/gen-function.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { difference, intersection } from "@lambdalisue/set-operations";
21
import * as path from "@std/path";
32
import { parse } from "./parse.ts";
43
import { format } from "./format.ts";
@@ -45,7 +44,7 @@ for (const vimHelpDownloadUrl of vimHelpDownloadUrls) {
4544
}
4645
const vimHelps = await Promise.all(vimHelpDownloadUrls.map(downloadString));
4746
const vimDefs = parse(vimHelps.join("\n"));
48-
const vimFnSet = difference(new Set(vimDefs.map((def) => def.fn)), manualFnSet);
47+
const vimFnSet = new Set(vimDefs.map((def) => def.fn)).difference(manualFnSet);
4948

5049
const nvimHelpDownloadUrls = [
5150
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/api.txt`,
@@ -58,8 +57,7 @@ for (const nvimHelpDownloadUrl of nvimHelpDownloadUrls) {
5857
}
5958
const nvimHelps = await Promise.all(nvimHelpDownloadUrls.map(downloadString));
6059
const nvimDefs = parse(nvimHelps.join("\n"));
61-
const nvimFnSet = difference(
62-
new Set(nvimDefs.map((def) => def.fn)),
60+
const nvimFnSet = new Set(nvimDefs.map((def) => def.fn)).difference(
6361
manualFnSet,
6462
);
6563

@@ -71,9 +69,9 @@ const commonDefs = vimDefs
7169
: vimDef
7270
);
7371

74-
const commonFnSet = intersection(vimFnSet, nvimFnSet);
75-
const vimOnlyFnSet = difference(vimFnSet, nvimFnSet);
76-
const nvimOnlyFnSet = difference(nvimFnSet, vimFnSet);
72+
const commonFnSet = vimFnSet.intersection(nvimFnSet);
73+
const vimOnlyFnSet = vimFnSet.difference(nvimFnSet);
74+
const nvimOnlyFnSet = nvimFnSet.difference(vimFnSet);
7775

7876
const commonCode = format(
7977
commonDefs.filter((def) => commonFnSet.has(def.fn)),

.scripts/gen-option/gen-option.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { difference, intersection } from "@lambdalisue/set-operations";
21
import * as path from "@std/path";
32
import { parse } from "./parse.ts";
43
import { format } from "./format.ts";
@@ -38,8 +37,7 @@ for (const vimHelpDownloadUrl of vimHelpDownloadUrls) {
3837
}
3938
const vimHelps = await Promise.all(vimHelpDownloadUrls.map(downloadString));
4039
const vimDefs = vimHelps.map(parse).flat();
41-
const vimOptionSet = difference(
42-
new Set(vimDefs.map((def) => def.name)),
40+
const vimOptionSet = new Set(vimDefs.map((def) => def.name)).difference(
4341
manualOptionSet,
4442
);
4543

@@ -51,8 +49,7 @@ for (const nvimHelpDownloadUrl of nvimHelpDownloadUrls) {
5149
}
5250
const nvimHelps = await Promise.all(nvimHelpDownloadUrls.map(downloadString));
5351
const nvimDefs = nvimHelps.map(parse).flat();
54-
const nvimOptionSet = difference(
55-
new Set(nvimDefs.map((def) => def.name)),
52+
const nvimOptionSet = new Set(nvimDefs.map((def) => def.name)).difference(
5653
manualOptionSet,
5754
);
5855

@@ -64,9 +61,9 @@ const commonDefs = vimDefs
6461
: vimDef
6562
);
6663

67-
const commonOptionSet = intersection(vimOptionSet, nvimOptionSet);
68-
const vimOnlyOptionSet = difference(vimOptionSet, nvimOptionSet);
69-
const nvimOnlyOptionSet = difference(nvimOptionSet, vimOptionSet);
64+
const commonOptionSet = vimOptionSet.intersection(nvimOptionSet);
65+
const vimOnlyOptionSet = vimOptionSet.difference(nvimOptionSet);
66+
const nvimOnlyOptionSet = nvimOptionSet.difference(vimOptionSet);
7067

7168
const commonCode = format(
7269
commonDefs.filter((def) => commonOptionSet.has(def.name)),

.scripts/transform.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { fromFileUrl, toFileUrl } from "@std/path";
2-
import { intersection } from "@lambdalisue/set-operations";
32

43
interface ModuleInformation {
54
sourcePath: string;
@@ -76,7 +75,7 @@ export async function transform(
7675
const fnNames = new Set(fnJSDocs.keys());
7776
const informations = await findExportModules(rootSourcePath);
7877
for (const { sourcePath, sourceText, functions } of informations) {
79-
if (intersection(functions, fnNames).size > 0) {
78+
if (functions.intersection(fnNames).size > 0) {
8079
const transformed = replaceFunctionDocs(sourceText, fnJSDocs);
8180
await Deno.writeTextFile(sourcePath, transformed);
8281
}

deno.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"@denops/test": "jsr:@denops/test@^2.0.0",
3838
"@lambdalisue/errorutil": "jsr:@lambdalisue/errorutil@^1.0.0",
3939
"@lambdalisue/itertools": "jsr:@lambdalisue/itertools@^1.1.2",
40-
"@lambdalisue/set-operations": "jsr:@lambdalisue/set-operations@^1.2.0",
4140
"@lambdalisue/unreachable": "jsr:@lambdalisue/unreachable@^1.0.1",
4241
"@std/assert": "jsr:@std/assert@^0.225.1",
4342
"@std/fs": "jsr:@std/fs@^0.224.0",

0 commit comments

Comments
 (0)