Skip to content

Commit a7a89d5

Browse files
authored
chore: upgrade deps (#53)
* chore: pin node version with volta * chore: update eslint * chore: fix test suite * chore: run eslint auto fix * chore: add prettier * chore: run prettier-write * chore: update test script * chore: update babel deps * chore: setup workflow file
1 parent d477b16 commit a7a89d5

147 files changed

Lines changed: 9730 additions & 17749 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.yml

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

.github/workflows/nodejs.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
nodejs:
11+
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
12+
with:
13+
node-version: '24.x'
14+
node-version-matrix: '[24]'
15+
disable-test-package: true
16+
upload-coverage: false

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tiles/font-awesome
2+
util/aesjs.js
3+
util/cloneDeepLimitArray.js
4+
util/md5.js
5+
util/yamlParser.js,
6+
spectra-data/conrec.js

.travis.yml

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

ChemEquilibrium/AcidModel.js

Lines changed: 178 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,151 @@
1-
2-
var pkas = [{ ha: 'HIO3', a: 'IO3-', pka: 0.8, specie: { label: 'IO3-', number: 1, pka: 0.8 } }, { ha: 'H3PO4', a: 'H2PO4-', pka: 2.16, specie: { label: 'PO4---', number: 3, pka: 21.69 } }, { ha: 'H2PO4-', a: 'HPO4--', pka: 7.21, specie: { label: 'PO4---', number: 2, pka: 19.53 } }, { ha: 'HPO4--', a: 'PO4---', pka: 12.32, specie: { label: 'PO4---', number: 1, pka: 12.32 } }, { ha: 'HF', a: 'F-', pka: 3.2, specie: { label: 'F-', number: 1, pka: 3.2 } }, { ha: 'HNO2', a: 'NO2-', pka: 3.25, specie: { label: 'NO2-', number: 1, pka: 3.25 } }, { ha: 'HOCN', a: 'OCN-', pka: 3.48, specie: { label: 'OCN-', number: 1, pka: 3.48 } }, { ha: 'H2CO3', a: 'HCO3-', pka: 6.35, specie: { label: 'CO3--', number: 2, pka: 16.68 } }, { ha: 'HCO3-', a: 'CO3--', pka: 10.33, specie: { label: 'CO3--', number: 1, pka: 10.33 } }, { ha: 'H2S', a: 'HS-', pka: 7.05, specie: { label: 'S--', number: 2, pka: 19.14 } }, { ha: 'HS-', a: 'S--', pka: 12.09, specie: { label: 'S--', number: 1, pka: 12.09 } }, { ha: 'HClO', a: 'ClO-', pka: 7.4, specie: { label: 'ClO-', number: 1, pka: 7.4 } }, { ha: 'HBrO', a: 'BrO-', pka: 8.6, specie: { label: 'BrO-', number: 1, pka: 8.6 } }, { ha: 'HCN', a: 'CN-', pka: 9.21, specie: { label: 'CN-', number: 1, pka: 9.21 } }, { ha: 'NH4+', a: 'NH3', pka: 9.25, specie: { label: 'NH3', number: 1, pka: 9.25 } }, { ha: 'CH2ClCOOH', a: 'CH2ClCOO-', pka: 2.89, specie: { label: 'CH2ClCOO-', number: 1, pka: 2.89 } }, { ha: 'HCOOH', a: 'HCOO-', pka: 3.75, specie: { label: 'HCOO-', number: 1, pka: 3.75 } }, { ha: 'C6H5COOH', a: 'C6H5COO-', pka: 4.2, specie: { label: 'C6H5COO-', number: 1, pka: 4.2 } }, { ha: 'C66H5NH3+', a: 'C66H5NH2', pka: 4.6, specie: { label: 'C66H5NH2', number: 1, pka: 4.6 } }, { ha: 'CH3COOH', a: 'CH3COO-', pka: 4.75, specie: { label: 'CH3COO-', number: 1, pka: 4.75 } }, { ha: 'C2H5COOH', a: 'C2H5COO-', pka: 4.87, specie: { label: 'C2H5COO-', number: 1, pka: 4.87 } }, { ha: 'C5H5NH+', a: 'C5H5N', pka: 5.25, specie: { label: 'C5H5N', number: 1, pka: 5.25 } }, { ha: 'CH3NH3+', a: 'CH3NH2', pka: 10.66, specie: { label: 'CH3NH2', number: 1, pka: 10.66 } }, { ha: '(C2H5)3NH+', a: '(C2H5)3N', pka: 10.75, specie: { label: '(C2H5)3N', number: 1, pka: 10.75 } }, { ha: 'C2H5NH3+', a: 'C2H5NH2', pka: 10.8, specie: { label: 'C2H5NH2', number: 1, pka: 10.8 } }, { ha: 'HCl', a: 'Cl-', pka: 1, specie: { label: 'Cl-', number: 1, pka: 1 } }];
1+
let pkas = [
2+
{
3+
ha: 'HIO3',
4+
a: 'IO3-',
5+
pka: 0.8,
6+
specie: { label: 'IO3-', number: 1, pka: 0.8 },
7+
},
8+
{
9+
ha: 'H3PO4',
10+
a: 'H2PO4-',
11+
pka: 2.16,
12+
specie: { label: 'PO4---', number: 3, pka: 21.69 },
13+
},
14+
{
15+
ha: 'H2PO4-',
16+
a: 'HPO4--',
17+
pka: 7.21,
18+
specie: { label: 'PO4---', number: 2, pka: 19.53 },
19+
},
20+
{
21+
ha: 'HPO4--',
22+
a: 'PO4---',
23+
pka: 12.32,
24+
specie: { label: 'PO4---', number: 1, pka: 12.32 },
25+
},
26+
{ ha: 'HF', a: 'F-', pka: 3.2, specie: { label: 'F-', number: 1, pka: 3.2 } },
27+
{
28+
ha: 'HNO2',
29+
a: 'NO2-',
30+
pka: 3.25,
31+
specie: { label: 'NO2-', number: 1, pka: 3.25 },
32+
},
33+
{
34+
ha: 'HOCN',
35+
a: 'OCN-',
36+
pka: 3.48,
37+
specie: { label: 'OCN-', number: 1, pka: 3.48 },
38+
},
39+
{
40+
ha: 'H2CO3',
41+
a: 'HCO3-',
42+
pka: 6.35,
43+
specie: { label: 'CO3--', number: 2, pka: 16.68 },
44+
},
45+
{
46+
ha: 'HCO3-',
47+
a: 'CO3--',
48+
pka: 10.33,
49+
specie: { label: 'CO3--', number: 1, pka: 10.33 },
50+
},
51+
{
52+
ha: 'H2S',
53+
a: 'HS-',
54+
pka: 7.05,
55+
specie: { label: 'S--', number: 2, pka: 19.14 },
56+
},
57+
{
58+
ha: 'HS-',
59+
a: 'S--',
60+
pka: 12.09,
61+
specie: { label: 'S--', number: 1, pka: 12.09 },
62+
},
63+
{
64+
ha: 'HClO',
65+
a: 'ClO-',
66+
pka: 7.4,
67+
specie: { label: 'ClO-', number: 1, pka: 7.4 },
68+
},
69+
{
70+
ha: 'HBrO',
71+
a: 'BrO-',
72+
pka: 8.6,
73+
specie: { label: 'BrO-', number: 1, pka: 8.6 },
74+
},
75+
{
76+
ha: 'HCN',
77+
a: 'CN-',
78+
pka: 9.21,
79+
specie: { label: 'CN-', number: 1, pka: 9.21 },
80+
},
81+
{
82+
ha: 'NH4+',
83+
a: 'NH3',
84+
pka: 9.25,
85+
specie: { label: 'NH3', number: 1, pka: 9.25 },
86+
},
87+
{
88+
ha: 'CH2ClCOOH',
89+
a: 'CH2ClCOO-',
90+
pka: 2.89,
91+
specie: { label: 'CH2ClCOO-', number: 1, pka: 2.89 },
92+
},
93+
{
94+
ha: 'HCOOH',
95+
a: 'HCOO-',
96+
pka: 3.75,
97+
specie: { label: 'HCOO-', number: 1, pka: 3.75 },
98+
},
99+
{
100+
ha: 'C6H5COOH',
101+
a: 'C6H5COO-',
102+
pka: 4.2,
103+
specie: { label: 'C6H5COO-', number: 1, pka: 4.2 },
104+
},
105+
{
106+
ha: 'C66H5NH3+',
107+
a: 'C66H5NH2',
108+
pka: 4.6,
109+
specie: { label: 'C66H5NH2', number: 1, pka: 4.6 },
110+
},
111+
{
112+
ha: 'CH3COOH',
113+
a: 'CH3COO-',
114+
pka: 4.75,
115+
specie: { label: 'CH3COO-', number: 1, pka: 4.75 },
116+
},
117+
{
118+
ha: 'C2H5COOH',
119+
a: 'C2H5COO-',
120+
pka: 4.87,
121+
specie: { label: 'C2H5COO-', number: 1, pka: 4.87 },
122+
},
123+
{
124+
ha: 'C5H5NH+',
125+
a: 'C5H5N',
126+
pka: 5.25,
127+
specie: { label: 'C5H5N', number: 1, pka: 5.25 },
128+
},
129+
{
130+
ha: 'CH3NH3+',
131+
a: 'CH3NH2',
132+
pka: 10.66,
133+
specie: { label: 'CH3NH2', number: 1, pka: 10.66 },
134+
},
135+
{
136+
ha: '(C2H5)3NH+',
137+
a: '(C2H5)3N',
138+
pka: 10.75,
139+
specie: { label: '(C2H5)3N', number: 1, pka: 10.75 },
140+
},
141+
{
142+
ha: 'C2H5NH3+',
143+
a: 'C2H5NH2',
144+
pka: 10.8,
145+
specie: { label: 'C2H5NH2', number: 1, pka: 10.8 },
146+
},
147+
{ ha: 'HCl', a: 'Cl-', pka: 1, specie: { label: 'Cl-', number: 1, pka: 1 } },
148+
];
3149

4150
define(['lodash'], function (_) {
5151
class AcidBase {
@@ -9,17 +155,17 @@ define(['lodash'], function (_) {
9155
}
10156

11157
static getAllAcidBaseLabels() {
12-
var species = new Set();
13-
for (var i = 0; i < pkas.length; i++) {
158+
let species = new Set();
159+
for (let i = 0; i < pkas.length; i++) {
14160
species.add(pkas[i].ha);
15161
species.add(pkas[i].a);
16162
}
17163
return Array.from(species);
18164
}
19165

20166
addAcidBase(label, total) {
21-
var titrProtonCount;
22-
var titrSpecie = pkas.find(function (pka) {
167+
let titrProtonCount;
168+
let titrSpecie = pkas.find(function (pka) {
23169
return pka.ha === label;
24170
});
25171
if (titrSpecie) {
@@ -31,13 +177,11 @@ define(['lodash'], function (_) {
31177
});
32178
if (titrSpecie) {
33179
titrProtonCount = 0;
180+
} else if (label === 'OH-') {
181+
this.addComponent('OH-', total);
182+
return;
34183
} else {
35-
if (label === 'OH-') {
36-
this.addComponent('OH-', total);
37-
return;
38-
} else {
39-
throw new Error('Could not find acid/base');
40-
}
184+
throw new Error('Could not find acid/base');
41185
}
42186
titrSpecie = titrSpecie.specie.label;
43187
}
@@ -52,81 +196,82 @@ define(['lodash'], function (_) {
52196
total = -total;
53197
}
54198
if (!total) total = 0;
55-
var comp = this.components.find((c) => c.label === label);
199+
let comp = this.components.find((c) => c.label === label);
56200
if (comp) {
57201
comp.total += total;
58202
} else {
59203
this.components.push({
60-
label, total
204+
label,
205+
total,
61206
});
62207
}
63208
}
64209

65210
setTotal(componentLabel, total) {
66-
var c = this.components.find((c) => c.label === componentLabel);
211+
let c = this.components.find((c) => c.label === componentLabel);
67212
c.total = total;
68213
c.atEquilibrium = undefined;
69214
}
70215

71216
setAtEquilibrium(componentLabel, atEquilibrium) {
72-
var c = this.components.find((c) => c.label === componentLabel);
217+
let c = this.components.find((c) => c.label === componentLabel);
73218
c.atEquilibrium = atEquilibrium;
74219
c.total = undefined;
75220
}
76221

77222
getModel() {
78223
// Get all involved pkas
79-
var pkas = this.pkas.filter((pka) => {
224+
let pkas = this.pkas.filter((pka) => {
80225
return this.components.find(function (c) {
81226
return String(c.label) === String(pka.specie.label);
82227
});
83228
});
84229

85230
// group pkas by component
86-
var grouped = _.groupBy(pkas, function (pka) {
231+
let grouped = _.groupBy(pkas, function (pka) {
87232
return String(pka.specie.label);
88233
});
89234

235+
let nbComponents = this.components.length;
90236

91-
var nbComponents = this.components.length;
92-
93-
var protonIndex = this.components.findIndex((c) => c.label === 'H+');
237+
let protonIndex = this.components.findIndex((c) => c.label === 'H+');
94238
if (protonIndex === -1) throw new Error('Acid-base model has no proton');
95239

96-
var model = {};
240+
let model = {};
97241

98242
// Model components
99243
model.components = new Array(nbComponents);
100244
for (i = 0; i < this.components.length; i++) {
101-
model.components[i] = Object.assign({}, this.components[i]);
245+
model.components[i] = { ...this.components[i] };
102246
}
103247

104248
// Model formed species
105249
model.formedSpecies = [
106250
{
107251
label: 'OH-',
108-
beta: Math.pow(10, -14),
109-
components: new Array(nbComponents).fill(0)
110-
}
252+
beta: 10 ** -14,
253+
components: new Array(nbComponents).fill(0),
254+
},
111255
];
112256

113257
model.formedSpecies[0].components[protonIndex] = -1;
114258

115-
116259
for (var i = 0; i < this.components.length; i++) {
117260
if (i === protonIndex) continue;
118-
var group = grouped[this.components[i].label];
261+
let group = grouped[this.components[i].label];
119262
if (!group) throw new Error('Should be unreachable');
120263

121-
for (var j = 0; j < group.length; j++) {
122-
var el = group[j];
264+
for (let j = 0; j < group.length; j++) {
265+
let el = group[j];
123266
model.formedSpecies.push({
124267
label: String(el.ha),
125-
beta: Math.pow(10, Number(el.specie.pka)),
126-
components: new Array(nbComponents).fill(0)
268+
beta: 10 ** Number(el.specie.pka),
269+
components: new Array(nbComponents).fill(0),
127270
});
128271
model.formedSpecies[model.formedSpecies.length - 1].components[i] = 1;
129-
model.formedSpecies[model.formedSpecies.length - 1].components[protonIndex] = Number(el.specie.number);
272+
model.formedSpecies[model.formedSpecies.length - 1].components[
273+
protonIndex
274+
] = Number(el.specie.number);
130275
}
131276
}
132277

ChemEquilibrium/chart.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ define(['src/util/color'], function (Color) {
55
if (x.length !== y.length || y.length === 0) {
66
throw new Error('Invalid data length');
77
}
8-
var chart = {
8+
let chart = {
99
data: [],
1010
axis: [
1111
{
12-
label: options.xLabel || ''
12+
label: options.xLabel || '',
1313
},
1414
{
15-
label: options.yLabel || ''
16-
}
17-
]
15+
label: options.yLabel || '',
16+
},
17+
],
1818
};
1919

20-
var species = Object.keys(y[0]);
21-
var colors = Color.getDistinctColors(species.length);
20+
let species = Object.keys(y[0]);
21+
let colors = Color.getDistinctColors(species.length);
2222

2323
for (var i = 0; i < species.length; i++) {
24-
var data = {};
24+
let data = {};
2525
chart.data.push(data);
2626
// eslint-disable-next-line no-loop-func
2727
data.y = y.map((y) => {
@@ -37,10 +37,10 @@ define(['src/util/color'], function (Color) {
3737
data.yAxis = 1;
3838
data.defaultStyle = {
3939
lineColor: colors[i],
40-
lineWidth: 1
40+
lineWidth: 1,
4141
};
4242
}
4343
return chart;
44-
}
44+
},
4545
};
4646
});

0 commit comments

Comments
 (0)