Skip to content

Commit f73f798

Browse files
committed
chore: update dependencies
1 parent c5010ee commit f73f798

File tree

11 files changed

+51
-50
lines changed

11 files changed

+51
-50
lines changed

package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,27 @@
2727
"check-types": "tsc --noEmit",
2828
"clean": "rimraf lib lib-esm",
2929
"eslint": "eslint src --cache",
30-
"eslint:fix": "npm run eslint -- --fix",
30+
"eslint-fix": "npm run eslint -- --fix",
3131
"prepack": "npm run tsc",
3232
"prettier": "prettier --check src",
33-
"prettier:fix": "prettier --write src",
33+
"prettier-write": "prettier --write src",
3434
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
3535
"test-only": "jest --coverage",
3636
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
3737
"tsc-cjs": "tsc --project tsconfig.cjs.json",
3838
"tsc-esm": "tsc --project tsconfig.esm.json"
3939
},
4040
"devDependencies": {
41-
"@types/jest": "^29.2.3",
42-
"cheminfo-build": "^1.1.11",
43-
"cheminfo-types": "^1.4.0",
44-
"eslint": "^8.25.0",
45-
"eslint-config-cheminfo-typescript": "^11.2.2",
46-
"eslint-plugin-import": "^2.28.0",
47-
"jest": "^29.3.1",
48-
"prettier": "^2.7.1",
49-
"ts-jest": "^29.0.3",
50-
"typescript": "^4.9.3"
41+
"@types/jest": "^29.5.3",
42+
"cheminfo-types": "^1.7.2",
43+
"eslint": "^8.46.0",
44+
"eslint-config-cheminfo-typescript": "^12.0.4",
45+
"jest": "^29.6.2",
46+
"prettier": "^3.0.1",
47+
"ts-jest": "^29.1.1",
48+
"typescript": "^5.1.6"
5149
},
5250
"dependencies": {
53-
"iobuffer": "^5.2.1"
51+
"iobuffer": "^5.3.2"
5452
}
5553
}

src/__tests__/attributeExists.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const pathFiles = `${__dirname}/files/`;
77
test('attributeExists', () => {
88
const data = readFileSync(`${pathFiles}P071.CDF`);
99

10-
let reader = new NetCDFReader(data);
10+
const reader = new NetCDFReader(data);
1111
expect(reader.attributeExists('operator_name')).toBe(true);
1212
expect(reader.attributeExists('operator_nameXX')).toBe(false);
1313
});

src/__tests__/dataVariableExists.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const pathFiles = `${__dirname}/files/`;
77
test('dataVariableExists', () => {
88
const data = readFileSync(`${pathFiles}P071.CDF`);
99

10-
let reader = new NetCDFReader(data);
10+
const reader = new NetCDFReader(data);
1111
expect(reader.dataVariableExists('instrument_name')).toBe(true);
1212
expect(reader.dataVariableExists('instrument_nameXX')).toBe(false);
1313
});

src/__tests__/getAttribute.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ const pathFiles = `${__dirname}/files/`;
77
test('getAttribute', () => {
88
const data = readFileSync(`${pathFiles}P071.CDF`);
99

10-
let reader = new NetCDFReader(data);
10+
const reader = new NetCDFReader(data);
1111
expect(reader.getAttribute('operator_name')).toBe('SC');
1212
});

src/__tests__/getDataVariableAsString.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const pathFiles = `${__dirname}/files/`;
77
test('getDataVariableAsString', () => {
88
const data = readFileSync(`${pathFiles}P071.CDF`);
99

10-
let reader = new NetCDFReader(data);
10+
const reader = new NetCDFReader(data);
1111
expect(reader.getDataVariableAsString('instrument_name')).toBe(
1212
'Gas Chromatograph',
1313
);

src/__tests__/index.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Read file', () => {
1717
// http://www.unidata.ucar.edu/software/netcdf/examples/madis-sao.cdl
1818
const data = readFileSync(`${pathFiles}madis-sao.nc`);
1919

20-
let reader = new NetCDFReader(data);
20+
const reader = new NetCDFReader(data);
2121
expect(reader.version).toBe('classic format');
2222
expect(reader.recordDimension).toStrictEqual({
2323
length: 178,
@@ -94,14 +94,14 @@ describe('Read file', () => {
9494

9595
it('read non-record variable', () => {
9696
const data = readFileSync(`${pathFiles}madis-sao.nc`);
97-
let reader = new NetCDFReader(data);
97+
const reader = new NetCDFReader(data);
9898

9999
expect(reader.getDataVariable('nStaticIds')[0]).toBe(145);
100100
});
101101

102102
it('read 2 dimensional variable', () => {
103103
const data = readFileSync(`${pathFiles}ichthyop.nc`);
104-
let reader = new NetCDFReader(data);
104+
const reader = new NetCDFReader(data);
105105
expect(reader.getDataVariable('time')).toHaveLength(49);
106106
expect(reader.getDataVariable('time')[0]).toBe(1547070300);
107107
expect(reader.getDataVariable('lat')).toHaveLength(49);
@@ -112,21 +112,21 @@ describe('Read file', () => {
112112

113113
it('read record variable with string', () => {
114114
const data = readFileSync(`${pathFiles}madis-sao.nc`);
115-
let reader = new NetCDFReader(data);
115+
const reader = new NetCDFReader(data);
116116

117-
let record = reader.getDataVariable('wmoId');
117+
const record = reader.getDataVariable('wmoId');
118118
expect(record[0]).toBe(71419);
119119
expect(record[1]).toBe(71415);
120120
expect(record[2]).toBe(71408);
121121
});
122122

123123
it('read non-record variable with object', () => {
124124
const data = readFileSync(`${pathFiles}madis-sao.nc`);
125-
let reader = new NetCDFReader(data);
126-
let variables = reader.variables;
125+
const reader = new NetCDFReader(data);
126+
const variables = reader.variables;
127127

128-
let withString = reader.getDataVariable('staticIds');
129-
let withObject = reader.getDataVariable(variables[1]);
128+
const withString = reader.getDataVariable('staticIds');
129+
const withObject = reader.getDataVariable(variables[1]);
130130
expect(withString[0]).toBe('W');
131131
expect(withString[1]).toBe('A');
132132
expect(withString[2]).toBe('F');
@@ -137,7 +137,7 @@ describe('Read file', () => {
137137

138138
it('read non-existent variable string', () => {
139139
const data = readFileSync(`${pathFiles}madis-sao.nc`);
140-
let reader = new NetCDFReader(data);
140+
const reader = new NetCDFReader(data);
141141

142142
expect(reader.getDataVariable.bind(reader, "n'importe quoi")).toThrow(
143143
'Not a valid NetCDF v3.x file: variable not found',
@@ -146,21 +146,21 @@ describe('Read file', () => {
146146

147147
it('read 64 bit offset file', () => {
148148
const data = readFileSync(`${pathFiles}model1_md2.nc`);
149-
let reader = new NetCDFReader(data);
149+
const reader = new NetCDFReader(data);
150150
expect(reader.version).toBe('64-bit offset format');
151151
expect(reader.getDataVariable('cell_angular')[0]).toBe('a');
152152
expect(reader.getDataVariable('cell_spatial')[0]).toBe('a');
153153
});
154154

155155
it('read agilent hplc file file', () => {
156156
const data = readFileSync(`${pathFiles}agilent_hplc.cdf`);
157-
let reader = new NetCDFReader(data);
157+
const reader = new NetCDFReader(data);
158158

159159
expect(reader.version).toBe('classic format');
160160

161-
let variables = [];
161+
const variables = [];
162162

163-
for (let variable of reader.variables) {
163+
for (const variable of reader.variables) {
164164
const value = reader.getDataVariable(variable);
165165
variables.push({ value, ...variable });
166166
}

src/__tests__/toString.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ const pathFiles = `${__dirname}/files/`;
77
test('toString', () => {
88
const data = readFileSync(`${pathFiles}P071.CDF`);
99

10-
let reader = new NetCDFReader(data);
10+
const reader = new NetCDFReader(data);
1111
expect(reader.toString()).toMatchSnapshot();
1212
});

src/data.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import { num2bytes, str2num, readType } from './types';
1313
export function nonRecord(
1414
buffer: IOBuffer,
1515
variable: Header['variables'][number],
16-
): ReturnType<typeof readType>[] {
16+
): Array<ReturnType<typeof readType>> {
1717
// variable type
1818
const type = str2num(variable.type);
1919

2020
// size of the data
2121
const size = variable.size / num2bytes(type);
2222

2323
// iterates over the data
24-
let data = new Array(size);
24+
const data = new Array(size);
2525
for (let i = 0; i < size; i++) {
2626
data[i] = readType(buffer, type, 1);
2727
}
@@ -40,7 +40,7 @@ export function record(
4040
buffer: IOBuffer,
4141
variable: Header['variables'][number],
4242
recordDimension: Header['recordDimension'],
43-
): ReturnType<typeof readType>[] {
43+
): Array<ReturnType<typeof readType>> {
4444
// variable type
4545
const type = str2num(variable.type);
4646
const width = variable.size ? variable.size / num2bytes(type) : 1;
@@ -50,11 +50,11 @@ export function record(
5050
const size = recordDimension.length;
5151

5252
// iterates over the data
53-
let data = new Array(size);
53+
const data = new Array(size);
5454
const step = recordDimension.recordStep;
5555
if (step) {
5656
for (let i = 0; i < size; i++) {
57-
let currentOffset = buffer.offset;
57+
const currentOffset = buffer.offset;
5858
data[i] = readType(buffer, type, width);
5959
buffer.seek(currentOffset + step);
6060
}

src/header.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export function header(buffer: IOBuffer, version: number): Header {
6666

6767
export interface Dimensions {
6868
/* that is an array of dimension object:*/
69-
dimensions: {
69+
dimensions: Array<{
7070
/* name of the dimension*/
7171
name: string;
7272
/* size of the dimension */
7373
size: number;
74-
}[];
74+
}>;
7575
/* id of the dimension that has unlimited size or undefined,*/
7676
recordId?: number;
7777
/* name of the dimension that has unlimited size */
@@ -203,7 +203,10 @@ export interface Variable {
203203
/* True if is a record variable, false otherwise (unlimited size) */
204204
record: boolean;
205205
}
206-
type Variables = { variables: Variable[]; recordStep: number };
206+
interface Variables {
207+
variables: Variable[];
208+
recordStep: number;
209+
}
207210
/**
208211
* @param buffer - Buffer for the file data
209212
* @param recordId - Id of the unlimited dimension (also called record dimension)
@@ -233,22 +236,22 @@ function variablesList(
233236
variables = new Array(variableSize);
234237
for (let v = 0; v < variableSize; v++) {
235238
// Read name
236-
let name = readName(buffer);
239+
const name = readName(buffer);
237240

238241
// Read dimensionality of the variable
239242
const dimensionality = buffer.readUint32();
240243

241244
// Index into the list of dimensions
242-
let dimensionsIds = new Array(dimensionality);
245+
const dimensionsIds = new Array(dimensionality);
243246
for (let dim = 0; dim < dimensionality; dim++) {
244247
dimensionsIds[dim] = buffer.readUint32();
245248
}
246249

247250
// Read variables size
248-
let attributes = attributesList(buffer);
251+
const attributes = attributesList(buffer);
249252

250253
// Read type
251-
let type = buffer.readUint32();
254+
const type = buffer.readUint32();
252255
notNetcdf(type < 1 && type > 6, `non valid type ${type}`);
253256

254257
// Read variable size

src/toString.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { NetCDFReader } from './parser';
22

33
export function toString(this: NetCDFReader) {
4-
let result = [];
4+
const result = [];
55
result.push('DIMENSIONS');
6-
for (let dimension of this.dimensions) {
6+
for (const dimension of this.dimensions) {
77
result.push(` ${dimension.name.padEnd(30)} = size: ${dimension.size}`);
88
}
99

1010
result.push('');
1111
result.push('GLOBAL ATTRIBUTES');
12-
for (let attribute of this.globalAttributes) {
12+
for (const attribute of this.globalAttributes) {
1313
result.push(` ${attribute.name.padEnd(30)} = ${attribute.value}`);
1414
}
1515

16-
let variables = JSON.parse(JSON.stringify(this.variables));
16+
const variables = JSON.parse(JSON.stringify(this.variables));
1717
result.push('');
1818
result.push('VARIABLES:');
19-
for (let variable of variables) {
19+
for (const variable of variables) {
2020
variable.value = this.getDataVariable(variable);
2121
let stringify = JSON.stringify(variable.value);
2222
if (stringify.length > 50) stringify = stringify.substring(0, 50);

0 commit comments

Comments
 (0)