Skip to content

Commit d197546

Browse files
committed
refactor!: migrate to TypeScript and ESM
1 parent ce24d49 commit d197546

15 files changed

+108
-79
lines changed

.babelrc.json

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

.github/workflows/documentationjs.yml

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

.github/workflows/nodejs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ jobs:
1010
nodejs:
1111
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
1212
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
13+
with:
14+
lint-check-types: true

.github/workflows/typedoc.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy TypeDoc on GitHub pages
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
env:
9+
NODE_VERSION: 22.x
10+
ENTRY_FILE: 'src/index.js'
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ env.NODE_VERSION }}
20+
- name: Install dependencies
21+
run: npm install
22+
- name: Build documentation
23+
uses: zakodium/typedoc-action@v2
24+
with:
25+
entry: ${{ env.ENTRY_FILE }}
26+
- name: Deploy to GitHub pages
27+
uses: JamesIves/github-pages-deploy-action@releases/v4
28+
with:
29+
token: ${{ secrets.BOT_TOKEN }}
30+
branch: gh-pages
31+
folder: docs
32+
clean: true

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sparse-matrix
1+
# ml-sparse-matrix
22

33
[![NPM version][npm-image]][npm-url]
44
[![coverage status][codecov-image]][codecov-url]
@@ -13,7 +13,7 @@ Sparse matrix library.
1313
## Usage
1414

1515
```js
16-
import { SparseMatrix } from "ml-sparse-matrix";
16+
import { SparseMatrix } from 'ml-sparse-matrix';
1717

1818
const matrix1 = new SparseMatrix([
1919
[1, 2],

benchmark/denseMatrix.mjs renamed to benchmark/denseMatrix.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ for (let i = 0; i < size; i++) {
1414
sum += product.get(i, j);
1515
}
1616
}
17-
console.log(sum)
17+
console.log(sum);
1818
console.timeEnd('dense');
19-
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
2-
31
import { SparseMatrix } from '../lib/index.js';
42

53
let size = 200;
64

7-
8-
95
console.time('dense');
106

117
const matrix1 = new SparseMatrix(size, size);
12-
fillSparseMatrix(matrix1)
8+
fillSparseMatrix(matrix1);
139

1410
const matrix2 = new SparseMatrix(size, size);
15-
fillSparseMatrix(matrix2)
11+
fillSparseMatrix(matrix2);
1612

1713
const product = new SparseMatrix(size, size);
1814
for (let i = 0; i < size; i++) {
1915
for (let j = 0; j < size; j++) {
2016
for (let k = 0; k < size; k++) {
21-
product.set(i, j, product.get(i, j) + matrix1.get(i, k) * matrix2.get(k, j));
17+
product.set(
18+
i,
19+
j,
20+
product.get(i, j) + matrix1.get(i, k) * matrix2.get(k, j),
21+
);
2222
}
2323
}
2424
}
@@ -30,12 +30,12 @@ for (let i = 0; i < size; i++) {
3030
}
3131
}
3232
console.timeEnd('dense');
33-
console.log(sum)
33+
console.log(sum);
3434

3535
function fillSparseMatrix(matrix) {
3636
for (let row = 0; row < matrix.rows; row++) {
3737
for (let column = 0; column < matrix.columns; column++) {
3838
matrix.set(row, column, 1);
3939
}
4040
}
41-
}
41+
}

benchmark/sparseMatrix.mjs renamed to benchmark/sparseMatrix.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ let size = 200;
55
console.time('dense');
66

77
const matrix = new SparseMatrix(size, size);
8-
fillSparseMatrix(matrix)
8+
fillSparseMatrix(matrix);
99

1010
const matrix2 = new SparseMatrix(size, size);
11-
fillSparseMatrix(matrix2)
11+
fillSparseMatrix(matrix2);
1212

1313
const product = matrix.mmul(matrix2);
1414
// sum of all the elements
@@ -19,12 +19,12 @@ for (let i = 0; i < size; i++) {
1919
}
2020
}
2121
console.timeEnd('dense');
22-
console.log(sum)
22+
console.log(sum);
2323

2424
function fillSparseMatrix(matrix) {
2525
for (let row = 0; row < matrix.rows; row++) {
2626
for (let column = 0; column < matrix.columns; column++) {
2727
matrix.set(row, column, 1);
2828
}
2929
}
30-
}
30+
}

eslint.config.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import cheminfo from 'eslint-config-cheminfo';
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import ts from 'eslint-config-cheminfo-typescript/base';
23

3-
export default [
4-
...cheminfo,
5-
{
6-
languageOptions: {
7-
},
8-
rules: {
9-
}
10-
}
11-
]
4+
export default defineConfig(globalIgnores(['lib']), ts, {
5+
files: ['benchmark/**'],
6+
rules: {
7+
'no-console': 'off',
8+
},
9+
});

0 commit comments

Comments
 (0)