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

Lines changed: 8 additions & 9 deletions
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

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
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

Lines changed: 22 additions & 11 deletions
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

Lines changed: 0 additions & 41 deletions
This file was deleted.

benches/table_derived.ts

Lines changed: 12 additions & 6 deletions
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

Lines changed: 12 additions & 6 deletions
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;

0 commit comments

Comments
 (0)