Skip to content

Commit

Permalink
feat: migrated to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
CMCDragonkai committed May 15, 2024
1 parent 620ea7b commit d64c7b3
Show file tree
Hide file tree
Showing 33 changed files with 3,380 additions and 2,966 deletions.
17 changes: 8 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
"jest": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
],
"plugins": [
"import"
],
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"import"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"linebreak-style": ["error", "unix"],
"no-empty": 1,
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ build:windows:
- windows
before_script:
- mkdir -Force "$CI_PROJECT_DIR/tmp"
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
script:
- .\scripts\choco-install.ps1
- refreshenv
Expand Down
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install
# build the dist
npm run build
# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests
npm run test
# lint the source code
Expand Down
33 changes: 22 additions & 11 deletions benches/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
#!/usr/bin/env ts-node

import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
import si from 'systeminformation';
import tableNotIndexed from './table_not_indexed';
import tableIndexed from './table_indexed';
import tableDerived from './table_derived';
import { benchesPath } from './utils.js';
import tableNotIndexed from './table_not_indexed.js';
import tableIndexed from './table_indexed.js';
import tableDerived from './table_derived.js';

async function main(): Promise<void> {
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
await fs.promises.mkdir(path.join(benchesPath, 'results'), {
recursive: true,
});
await tableNotIndexed();
await tableIndexed();
await tableDerived();
const resultFilenames = await fs.promises.readdir(
path.join(__dirname, 'results'),
path.join(benchesPath, 'results'),
);
const metricsFile = await fs.promises.open(
path.join(__dirname, 'results', 'metrics.txt'),
path.join(benchesPath, 'results', 'metrics.txt'),
'w',
);
let concatenating = false;
for (const resultFilename of resultFilenames) {
if (/.+_metrics\.txt$/.test(resultFilename)) {
const metricsData = await fs.promises.readFile(
path.join(__dirname, 'results', resultFilename),
path.join(benchesPath, 'results', resultFilename),
);
if (concatenating) {
await metricsFile.write('\n');
Expand All @@ -39,9 +43,16 @@ async function main(): Promise<void> {
system: 'model, manufacturer',
});
await fs.promises.writeFile(
path.join(__dirname, 'results', 'system.json'),
path.join(benchesPath, 'results', 'system.json'),
JSON.stringify(systemData, null, 2),
);
}

void main();
if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
Empty file removed benches/results/metrics.txt
Empty file.
41 changes: 0 additions & 41 deletions benches/results/system.json

This file was deleted.

18 changes: 12 additions & 6 deletions benches/table_derived.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import path from 'path';
import path from 'node:path';
import url from 'node:url';
import b from 'benny';
import Table from '@';
import { suiteCommon } from './utils';
import { suiteCommon } from './utils.js';
import Table from '#Table.js';

const filePath = url.fileURLToPath(import.meta.url);

async function main() {
const summary = await b.suite(
path.basename(__filename, path.extname(__filename)),
path.basename(filePath, path.extname(filePath)),
b.add('insert', () => {
const t = new Table(['a', 'b', 'c', 'd'], [['a', 'b', 'c', 'd']]);
return () => {
Expand Down Expand Up @@ -34,8 +37,11 @@ async function main() {
return summary;
}

if (require.main === module) {
void main();
if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
18 changes: 12 additions & 6 deletions benches/table_indexed.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import path from 'path';
import path from 'node:path';
import url from 'node:url';
import b from 'benny';
import Table from '@';
import { suiteCommon } from './utils';
import { suiteCommon } from './utils.js';
import Table from '#Table.js';

const filePath = url.fileURLToPath(import.meta.url);

async function main() {
const summary = await b.suite(
path.basename(__filename, path.extname(__filename)),
path.basename(filePath, path.extname(filePath)),
b.add('insert', () => {
const t = new Table(['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd']);
return () => {
Expand Down Expand Up @@ -34,8 +37,11 @@ async function main() {
return summary;
}

if (require.main === module) {
void main();
if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
18 changes: 12 additions & 6 deletions benches/table_not_indexed.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import path from 'path';
import path from 'node:path';
import url from 'node:url';
import b from 'benny';
import Table from '@';
import { suiteCommon } from './utils';
import { suiteCommon } from './utils.js';
import Table from '#Table.js';

const filePath = url.fileURLToPath(import.meta.url);

async function main() {
const summary = await b.suite(
path.basename(__filename, path.extname(__filename)),
path.basename(filePath, path.extname(filePath)),
b.add('insert row', () => {
const t = new Table(['a', 'b', 'c', 'd']);
return () => {
Expand Down Expand Up @@ -34,8 +37,11 @@ async function main() {
return summary;
}

if (require.main === module) {
void main();
if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
21 changes: 13 additions & 8 deletions benches/utils.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
import b from 'benny';
import { codeBlock } from 'common-tags';
import packageJson from '../package.json';
import packageJson from '../package.json' assert { type: 'json' };

const benchesPath = path.dirname(
path.dirname(url.fileURLToPath(import.meta.url)),
);

const suiteCommon = [
b.cycle(),
b.complete(),
b.save({
file: (summary) => summary.name,
folder: path.join(__dirname, '../results'),
folder: path.join(benchesPath, 'results'),
version: packageJson.version,
details: true,
}),
b.save({
file: (summary) => summary.name,
folder: path.join(__dirname, '../results'),
folder: path.join(benchesPath, 'results'),
version: packageJson.version,
format: 'chart.html',
}),
b.complete((summary) => {
const filePath = path.join(
__dirname,
'../results',
benchesPath,
'results',
summary.name + '_metrics.txt',
);
fs.writeFileSync(
Expand Down Expand Up @@ -58,4 +63,4 @@ const suiteCommon = [
}),
];

export { suiteCommon };
export { benchesPath, suiteCommon };
6 changes: 3 additions & 3 deletions docs/assets/main.js

Large diffs are not rendered by default.

Loading

0 comments on commit d64c7b3

Please sign in to comment.