Skip to content

Commit cec40d2

Browse files
committed
fix: update dependencies
1 parent 699d3e2 commit cec40d2

12 files changed

Lines changed: 77 additions & 65 deletions

.babelrc

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

.github/workflows/documentationjs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v6
1313
- name: Build documentation
1414
uses: zakodium/documentationjs-action@v1
1515
- name: Deploy to GitHub pages

.github/workflows/lactame.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ on:
55
types: [published]
66

77
env:
8-
NODE_VERSION: 18.x
8+
NODE_VERSION: 24.x
99

1010
jobs:
1111
deploy:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v6
1515
- name: Get package name
1616
run: echo "PACKAGE_NAME=$(jq .name package.json | tr -d '"')" >> $GITHUB_ENV
17-
- uses: actions/setup-node@v2
17+
- uses: actions/setup-node@v6
1818
with:
1919
node-version: ${{ env.NODE_VERSION }}
2020
- name: Install dependencies

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,19 @@
3939
},
4040
"homepage": "https://github.com/cheminfo/sdf-parser",
4141
"devDependencies": {
42-
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
43-
"@types/node": "^22.13.5",
44-
"@vitest/coverage-v8": "^3.0.7",
45-
"babel-eslint": "^10.1.0",
42+
"@types/node": "^25.2.3",
43+
"@vitest/coverage-v8": "^4.0.18",
4644
"callback-stream": "^1.1.0",
47-
"cheminfo-build": "^1.2.1",
45+
"cheminfo-build": "^1.3.2",
4846
"eslint": "^9.21.0",
49-
"eslint-config-cheminfo": "^13.0.0",
50-
"file-collection": "^1.0.0",
51-
"openchemlib": "^8.18.1",
52-
"prettier": "^3.5.2",
53-
"vitest": "^3.0.7"
47+
"eslint-config-cheminfo": "^17.1.0",
48+
"file-collection": "^6.6.0",
49+
"openchemlib": "^9.20.0",
50+
"prettier": "^3.8.1",
51+
"vitest": "^4.0.18"
5452
},
5553
"dependencies": {
5654
"dynamic-typing": "^1.0.1",
57-
"ensure-string": "^1.2.0"
55+
"ensure-string": "^2.0.0"
5856
}
5957
}

src/__tests__/checkOptions.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import fs from 'node:fs';
22

3-
import { describe, it, expect } from 'vitest';
3+
import { describe, expect, it } from 'vitest';
44

55
import { parse } from '..';
66

7-
let sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
8-
97
describe('SDF Parser options', () => {
10-
let result = parse(sdf, {
8+
const sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
9+
const result = parse(sdf, {
1110
exclude: ['Number of H-Donors'],
1211
include: ['Number of H-Donors', 'CLogP', 'Code'],
1312
modifiers: {
@@ -36,6 +35,7 @@ describe('SDF Parser options', () => {
3635

3736
it('Check molecules', () => {
3837
expect(result.molecules).toHaveLength(43);
38+
3939
let molecule = result.molecules[0];
4040

4141
expect(Object.keys(molecule)).toHaveLength(3);
@@ -48,12 +48,12 @@ describe('SDF Parser options', () => {
4848
it('should throw with non-string argument', () => {
4949
expect(() => {
5050
parse();
51-
}).toThrow(TypeError);
51+
}).toThrowError(TypeError);
5252
expect(() => {
5353
parse(42);
54-
}).toThrow(TypeError);
54+
}).toThrowError(TypeError);
5555
expect(() => {
5656
parse({});
57-
}).toThrow(TypeError);
57+
}).toThrowError(TypeError);
5858
});
5959
});

src/__tests__/checkUndefined.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import fs from 'node:fs';
22

3-
import { describe, it, expect } from 'vitest';
3+
import { describe, expect, it } from 'vitest';
44

55
import { parse } from '..';
66

7-
let sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
8-
97
describe('SDF Parser options and undefined', () => {
10-
let result = parse(sdf, {
8+
const sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
9+
const result = parse(sdf, {
1110
exclude: ['Number of H-Donors'],
1211
include: ['Number of H-Donors', 'CLogP', 'Code'],
1312
modifiers: {

src/__tests__/getEntriesBoundaries.test.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
import fs from 'node:fs';
22

3-
import { test, expect } from 'vitest';
3+
import { expect, test } from 'vitest';
44

55
import { getEntriesBoundaries } from '../getEntriesBoundaries';
66

7-
let sdf0 = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
8-
let sdf1 = fs.readFileSync(`${__dirname}/test1.sdf`, 'utf8');
9-
let sdf2 = fs.readFileSync(`${__dirname}/test2.sdf`, 'utf8');
10-
11-
for (const sdf of [sdf0, sdf1, sdf2]) {
12-
let eol = '\n';
13-
let header = new Set(sdf.slice(0, 1000));
14-
if (header.has('\r\n')) {
15-
eol = '\r\n';
16-
} else if (header.has('\r')) {
17-
eol = '\r';
18-
}
7+
test.for(['test', 'test1', 'test2'])(
8+
'Split should match regex behavior - %s.sdf',
9+
(file) => {
10+
const sdf = fs.readFileSync(`${__dirname}/${file}.sdf`, 'utf8');
11+
12+
const eol = getEol(sdf);
13+
14+
let sdfParts = sdf.split(new RegExp(String.raw`${eol}\$\$\$\$.*${eol}`));
1915

20-
test('Split should match regex behavior', () => {
21-
let sdfParts = sdf.split(new RegExp(`${eol}\\$\\$\\$\\$.*${eol}`));
2216
expect(sdfParts).toStrictEqual(
2317
getEntriesBoundaries(sdf, `${eol}$$$$`, eol).map((v) => sdf.slice(...v)),
2418
);
25-
});
19+
},
20+
);
21+
22+
function getEol(sdf) {
23+
// A set would not work for \r\n matching.
24+
// eslint-disable-next-line unicorn/prefer-set-has
25+
const header = sdf.slice(0, 1000);
26+
if (header.includes('\r\n')) {
27+
return '\r\n';
28+
} else if (header.includes('\r')) {
29+
return '\r';
30+
} else {
31+
return '\n';
32+
}
2633
}
2734

2835
test('should parse sdf files without EOL in the EOF', () => {

src/__tests__/index.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import fs from 'node:fs';
22

3-
import { describe, it, expect } from 'vitest';
3+
import { describe, expect, it } from 'vitest';
44

55
import { parse } from '..';
66

7-
let sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
8-
let sdf1 = fs.readFileSync(`${__dirname}/test1.sdf`, 'utf8');
7+
const sdf = fs.readFileSync(`${__dirname}/test.sdf`, 'utf8');
8+
const sdf1 = fs.readFileSync(`${__dirname}/test1.sdf`, 'utf8');
99

1010
describe('SDF Parser', () => {
11-
let result = parse(sdf);
11+
const result = parse(sdf);
1212

1313
it('Check statistics', () => {
1414
expect(result.statistics[0].counter).toBe(128);
@@ -25,6 +25,7 @@ describe('SDF Parser', () => {
2525

2626
it('Check molecules', () => {
2727
let molecule = result.molecules[0];
28+
2829
expect(molecule.Code).toContain('0100380824');
2930
expect(molecule.CLogP).toBe(2.7);
3031
expect(molecule.molfile.split('\n')).toHaveLength(37);
@@ -33,18 +34,18 @@ describe('SDF Parser', () => {
3334
it('should throw with non-string argument', () => {
3435
expect(() => {
3536
parse();
36-
}).toThrow(TypeError);
37+
}).toThrowError(TypeError);
3738
expect(() => {
3839
parse(42);
39-
}).toThrow(TypeError);
40+
}).toThrowError(TypeError);
4041
expect(() => {
4142
parse({});
42-
}).toThrow(TypeError);
43+
}).toThrowError(TypeError);
4344
});
4445
});
4546

4647
describe('SDF Parser no dynamicTyping', () => {
47-
let result = parse(sdf, {
48+
const result = parse(sdf, {
4849
dynamicTyping: false,
4950
});
5051

@@ -63,6 +64,7 @@ describe('SDF Parser no dynamicTyping', () => {
6364

6465
it('Check molecules', () => {
6566
let molecule = result.molecules[0];
67+
6668
expect(typeof molecule.Code).toBe('string');
6769
expect(typeof molecule.CLogP).toBe('string');
6870
expect(molecule.CLogP).toBe('2.700000000000000e+000');
@@ -71,8 +73,9 @@ describe('SDF Parser no dynamicTyping', () => {
7173
});
7274

7375
describe('SDF Parser one molecule', () => {
74-
let result = parse(sdf1);
7576
it('Check statistics', () => {
77+
const result = parse(sdf1);
78+
7679
expect(result.molecules).toHaveLength(1);
7780
});
7881
});

src/__tests__/iterator.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { join } from 'node:path';
33

44
import { FileCollection } from 'file-collection';
55
import { Molecule } from 'openchemlib';
6-
import { test, expect } from 'vitest';
6+
import { expect, test } from 'vitest';
77

88
import { iterator } from '../iterator';
99

@@ -80,6 +80,7 @@ test.skipIf(process.version.startsWith('v18'))(
8080
)) {
8181
results.push(entry);
8282
}
83+
8384
expect(results).toHaveLength(3);
8485
expect(results[1]).toMatchInlineSnapshot(`
8586
{
@@ -103,8 +104,10 @@ test.skipIf(process.version.startsWith('v18'))(
103104
",
104105
}
105106
`);
107+
106108
for (const entry of results) {
107109
const molecule = Molecule.fromMolfile(entry.molfile);
110+
108111
expect(molecule.getAllAtoms()).toBe(6);
109112
}
110113
},
@@ -123,6 +126,7 @@ test.skipIf(process.version.startsWith('v18'))(
123126
for await (const entry of iterator(stream)) {
124127
results.push(entry);
125128
}
129+
126130
expect(results).toHaveLength(7);
127131
expect(results[2]).toMatchInlineSnapshot(`
128132
{
@@ -163,8 +167,10 @@ test.skipIf(process.version.startsWith('v18'))(
163167
"nmrshiftdb2 ID": 2189,
164168
}
165169
`);
170+
166171
for (const entry of results) {
167172
const molecule = Molecule.fromMolfile(entry.molfile);
173+
168174
expect(molecule.getAllAtoms()).toBeGreaterThan(5);
169175
}
170176
},
@@ -235,8 +241,10 @@ test.skipIf(process.version.startsWith('v18'))(
235241
",
236242
}
237243
`);
244+
238245
for (const entry of results) {
239246
const molecule = Molecule.fromMolfile(entry.molfile);
247+
240248
expect(molecule.getAllAtoms()).toBeGreaterThan(6);
241249
}
242250
},
@@ -261,6 +269,7 @@ test('iterator on fileCollection stream and decompression on the fly', async ()
261269
)) {
262270
results.push(entry);
263271
}
272+
264273
expect(results).toHaveLength(128);
265274
expect(results[0]).toMatchInlineSnapshot(`
266275
{
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import fs from 'node:fs';
22

3-
import { describe, it, expect } from 'vitest';
3+
import { describe, expect, it } from 'vitest';
44

55
import { parse } from '..';
66

77
describe('SDF Parser of non well formatted file', () => {
8-
let sdf = fs.readFileSync(`${__dirname}/test2.sdf`, 'utf8');
9-
sdf = sdf.replaceAll('\r', '');
10-
let result = parse(sdf, { mixedEOL: true });
11-
128
it('Check molecules', () => {
13-
let molecules = result.molecules;
9+
let sdf = fs.readFileSync(`${__dirname}/test2.sdf`, 'utf8');
10+
sdf = sdf.replaceAll('\r', '');
11+
const result = parse(sdf, { mixedEOL: true });
12+
13+
const molecules = result.molecules;
14+
1415
expect(molecules).toHaveLength(7);
1516
});
1617
});

0 commit comments

Comments
 (0)