Skip to content

Commit d64c7b3

Browse files
committed
feat: migrated to esm
1 parent 620ea7b commit d64c7b3

33 files changed

+3380
-2966
lines changed

.eslintrc

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@
77
"jest": true
88
},
99
"parser": "@typescript-eslint/parser",
10-
"extends": [
11-
"eslint:recommended",
12-
"plugin:@typescript-eslint/recommended",
13-
"plugin:prettier/recommended",
14-
"prettier"
15-
],
16-
"plugins": [
17-
"import"
18-
],
1910
"parserOptions": {
2011
"project": "tsconfig.json",
2112
"sourceType": "module"
2213
},
14+
"plugins": [
15+
"import"
16+
],
17+
"extends": [
18+
"eslint:recommended",
19+
"plugin:@typescript-eslint/recommended",
20+
"plugin:prettier/recommended"
21+
],
2322
"rules": {
2423
"linebreak-style": ["error", "unix"],
2524
"no-empty": 1,

.github/workflows/codesee-arch-diagram.yml

-23
This file was deleted.

.gitlab-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ build:windows:
165165
- windows
166166
before_script:
167167
- mkdir -Force "$CI_PROJECT_DIR/tmp"
168+
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
168169
script:
169170
- .\scripts\choco-install.ps1
170171
- refreshenv

.npmrc

-2
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ npm install
2121
# build the dist
2222
npm run build
2323
# run the repl (this allows you to import from ./src)
24-
npm run ts-node
24+
npm run tsx
2525
# run the tests
2626
npm run test
2727
# lint the source code

benches/index.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
#!/usr/bin/env ts-node
22

3-
import fs from 'fs';
4-
import path from 'path';
3+
import fs from 'node:fs';
4+
import path from 'node:path';
5+
import url from 'node:url';
56
import si from 'systeminformation';
6-
import tableNotIndexed from './table_not_indexed';
7-
import tableIndexed from './table_indexed';
8-
import tableDerived from './table_derived';
7+
import { benchesPath } from './utils.js';
8+
import tableNotIndexed from './table_not_indexed.js';
9+
import tableIndexed from './table_indexed.js';
10+
import tableDerived from './table_derived.js';
911

1012
async function main(): Promise<void> {
11-
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
13+
await fs.promises.mkdir(path.join(benchesPath, 'results'), {
14+
recursive: true,
15+
});
1216
await tableNotIndexed();
1317
await tableIndexed();
1418
await tableDerived();
1519
const resultFilenames = await fs.promises.readdir(
16-
path.join(__dirname, 'results'),
20+
path.join(benchesPath, 'results'),
1721
);
1822
const metricsFile = await fs.promises.open(
19-
path.join(__dirname, 'results', 'metrics.txt'),
23+
path.join(benchesPath, 'results', 'metrics.txt'),
2024
'w',
2125
);
2226
let concatenating = false;
2327
for (const resultFilename of resultFilenames) {
2428
if (/.+_metrics\.txt$/.test(resultFilename)) {
2529
const metricsData = await fs.promises.readFile(
26-
path.join(__dirname, 'results', resultFilename),
30+
path.join(benchesPath, 'results', resultFilename),
2731
);
2832
if (concatenating) {
2933
await metricsFile.write('\n');
@@ -39,9 +43,16 @@ async function main(): Promise<void> {
3943
system: 'model, manufacturer',
4044
});
4145
await fs.promises.writeFile(
42-
path.join(__dirname, 'results', 'system.json'),
46+
path.join(benchesPath, 'results', 'system.json'),
4347
JSON.stringify(systemData, null, 2),
4448
);
4549
}
4650

47-
void main();
51+
if (import.meta.url.startsWith('file:')) {
52+
const modulePath = url.fileURLToPath(import.meta.url);
53+
if (process.argv[1] === modulePath) {
54+
void main();
55+
}
56+
}
57+
58+
export default main;

benches/results/metrics.txt

Whitespace-only changes.

benches/results/system.json

-41
This file was deleted.

benches/table_derived.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import path from 'path';
1+
import path from 'node:path';
2+
import url from 'node:url';
23
import b from 'benny';
3-
import Table from '@';
4-
import { suiteCommon } from './utils';
4+
import { suiteCommon } from './utils.js';
5+
import Table from '#Table.js';
6+
7+
const filePath = url.fileURLToPath(import.meta.url);
58

69
async function main() {
710
const summary = await b.suite(
8-
path.basename(__filename, path.extname(__filename)),
11+
path.basename(filePath, path.extname(filePath)),
912
b.add('insert', () => {
1013
const t = new Table(['a', 'b', 'c', 'd'], [['a', 'b', 'c', 'd']]);
1114
return () => {
@@ -34,8 +37,11 @@ async function main() {
3437
return summary;
3538
}
3639

37-
if (require.main === module) {
38-
void main();
40+
if (import.meta.url.startsWith('file:')) {
41+
const modulePath = url.fileURLToPath(import.meta.url);
42+
if (process.argv[1] === modulePath) {
43+
void main();
44+
}
3945
}
4046

4147
export default main;

benches/table_indexed.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import path from 'path';
1+
import path from 'node:path';
2+
import url from 'node:url';
23
import b from 'benny';
3-
import Table from '@';
4-
import { suiteCommon } from './utils';
4+
import { suiteCommon } from './utils.js';
5+
import Table from '#Table.js';
6+
7+
const filePath = url.fileURLToPath(import.meta.url);
58

69
async function main() {
710
const summary = await b.suite(
8-
path.basename(__filename, path.extname(__filename)),
11+
path.basename(filePath, path.extname(filePath)),
912
b.add('insert', () => {
1013
const t = new Table(['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd']);
1114
return () => {
@@ -34,8 +37,11 @@ async function main() {
3437
return summary;
3538
}
3639

37-
if (require.main === module) {
38-
void main();
40+
if (import.meta.url.startsWith('file:')) {
41+
const modulePath = url.fileURLToPath(import.meta.url);
42+
if (process.argv[1] === modulePath) {
43+
void main();
44+
}
3945
}
4046

4147
export default main;

benches/table_not_indexed.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import path from 'path';
1+
import path from 'node:path';
2+
import url from 'node:url';
23
import b from 'benny';
3-
import Table from '@';
4-
import { suiteCommon } from './utils';
4+
import { suiteCommon } from './utils.js';
5+
import Table from '#Table.js';
6+
7+
const filePath = url.fileURLToPath(import.meta.url);
58

69
async function main() {
710
const summary = await b.suite(
8-
path.basename(__filename, path.extname(__filename)),
11+
path.basename(filePath, path.extname(filePath)),
912
b.add('insert row', () => {
1013
const t = new Table(['a', 'b', 'c', 'd']);
1114
return () => {
@@ -34,8 +37,11 @@ async function main() {
3437
return summary;
3538
}
3639

37-
if (require.main === module) {
38-
void main();
40+
if (import.meta.url.startsWith('file:')) {
41+
const modulePath = url.fileURLToPath(import.meta.url);
42+
if (process.argv[1] === modulePath) {
43+
void main();
44+
}
3945
}
4046

4147
export default main;

benches/utils.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import url from 'node:url';
34
import b from 'benny';
45
import { codeBlock } from 'common-tags';
5-
import packageJson from '../package.json';
6+
import packageJson from '../package.json' assert { type: 'json' };
7+
8+
const benchesPath = path.dirname(
9+
path.dirname(url.fileURLToPath(import.meta.url)),
10+
);
611

712
const suiteCommon = [
813
b.cycle(),
914
b.complete(),
1015
b.save({
1116
file: (summary) => summary.name,
12-
folder: path.join(__dirname, '../results'),
17+
folder: path.join(benchesPath, 'results'),
1318
version: packageJson.version,
1419
details: true,
1520
}),
1621
b.save({
1722
file: (summary) => summary.name,
18-
folder: path.join(__dirname, '../results'),
23+
folder: path.join(benchesPath, 'results'),
1924
version: packageJson.version,
2025
format: 'chart.html',
2126
}),
2227
b.complete((summary) => {
2328
const filePath = path.join(
24-
__dirname,
25-
'../results',
29+
benchesPath,
30+
'results',
2631
summary.name + '_metrics.txt',
2732
);
2833
fs.writeFileSync(
@@ -58,4 +63,4 @@ const suiteCommon = [
5863
}),
5964
];
6065

61-
export { suiteCommon };
66+
export { benchesPath, suiteCommon };

docs/assets/main.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)