Upgrade package dependencies

This commit is contained in:
trekhleb
2026-02-18 01:13:21 -08:00
committed by Oleksii Trekhleb
parent 024884517f
commit 115e428168
16 changed files with 2138 additions and 1272 deletions

1
.husky/.gitignore vendored
View File

@@ -1 +0,0 @@
_

View File

@@ -1,5 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint
# npm run test

3313
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -32,19 +32,19 @@
"test": "jest",
"coverage": "npm run test -- --coverage",
"ci": "npm run lint && npm run coverage",
"prepare": "husky install"
"prepare": "husky"
},
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/preset-env": "7.20.2",
"@types/jest": "29.4.0",
"eslint": "8.33.0",
"eslint-config-airbnb": "19.0.4",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"husky": "8.0.3",
"jest": "29.4.1",
"@babel/cli": "^7.28.6",
"@babel/preset-env": "^7.29.0",
"@types/jest": "^30.0.0",
"eslint": "^8.57.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"husky": "^9.1.7",
"jest": "^30.2.0",
"pngjs": "^7.0.0"
},
"engines": {

View File

@@ -2,7 +2,7 @@ import { hillCipherEncrypt, hillCipherDecrypt } from '../hillCipher';
describe('hillCipher', () => {
it('should throw an exception when trying to decipher', () => {
expect(hillCipherDecrypt).toThrowError('This method is not implemented yet');
expect(hillCipherDecrypt).toThrow('This method is not implemented yet');
});
it('should throw an error when message or keyString contains none letter character', () => {
@@ -12,10 +12,10 @@ describe('hillCipher', () => {
const invalidCharacterInKeyString = () => {
hillCipherEncrypt('hello', 'hel12world');
};
expect(invalidCharacterInMessage).toThrowError(
expect(invalidCharacterInMessage).toThrow(
'The message and key string can only contain letters',
);
expect(invalidCharacterInKeyString).toThrowError(
expect(invalidCharacterInKeyString).toThrow(
'The message and key string can only contain letters',
);
});
@@ -24,7 +24,7 @@ describe('hillCipher', () => {
const invalidLengthOfKeyString = () => {
hillCipherEncrypt('ab', 'ab');
};
expect(invalidLengthOfKeyString).toThrowError(
expect(invalidLengthOfKeyString).toThrow(
'Invalid key string length. The square root of the key string must be an integer',
);
});
@@ -33,7 +33,7 @@ describe('hillCipher', () => {
const invalidLengthOfKeyString = () => {
hillCipherEncrypt('ab', 'aaabbbccc');
};
expect(invalidLengthOfKeyString).toThrowError(
expect(invalidLengthOfKeyString).toThrow(
'Invalid key string length. The key length must be a square of message length',
);
});

View File

@@ -30,7 +30,7 @@ describe('eulerianPath', () => {
eulerianPath(graph);
}
expect(findEulerianPathInNotEulerianGraph).toThrowError();
expect(findEulerianPathInNotEulerianGraph).toThrow();
});
it('should find Eulerian Circuit in graph', () => {

View File

@@ -11,7 +11,7 @@ describe('kruskal', () => {
kruskal(graph);
}
expect(applyPrimToDirectedGraph).toThrowError();
expect(applyPrimToDirectedGraph).toThrow();
});
it('should find minimum spanning tree', () => {

View File

@@ -11,7 +11,7 @@ describe('prim', () => {
prim(graph);
}
expect(applyPrimToDirectedGraph).toThrowError();
expect(applyPrimToDirectedGraph).toThrow();
});
it('should find minimum spanning tree', () => {

View File

@@ -12,11 +12,11 @@ describe('euclideanDistance', () => {
});
it('should throw an error in case if two matrices are of different shapes', () => {
expect(() => euclideanDistance([[1]], [[[2]]])).toThrowError(
expect(() => euclideanDistance([[1]], [[[2]]])).toThrow(
'Matrices have different dimensions',
);
expect(() => euclideanDistance([[1]], [[2, 3]])).toThrowError(
expect(() => euclideanDistance([[1]], [[2, 3]])).toThrow(
'Matrices have different shapes',
);
});

View File

@@ -4,16 +4,16 @@ describe('Matrix', () => {
it('should throw when trying to add matrices of invalid shapes', () => {
expect(
() => mtrx.dot([0], [1]),
).toThrowError('Invalid matrix format');
).toThrow('Invalid matrix format');
expect(
() => mtrx.dot([[0]], [1]),
).toThrowError('Invalid matrix format');
).toThrow('Invalid matrix format');
expect(
() => mtrx.dot([[[0]]], [[1]]),
).toThrowError('Matrix is not of 2D shape');
).toThrow('Matrix is not of 2D shape');
expect(
() => mtrx.dot([[0]], [[1], [2]]),
).toThrowError('Matrices have incompatible shape for multiplication');
).toThrow('Matrices have incompatible shape for multiplication');
});
it('should calculate matrices dimensions', () => {
@@ -252,7 +252,7 @@ describe('Matrix', () => {
it('should throw when trying to transpose non 2D matrix', () => {
expect(() => {
mtrx.t([[[1]]]);
}).toThrowError('Matrix is not of 2D shape');
}).toThrow('Matrix is not of 2D shape');
});
it('should add two matrices', () => {
@@ -316,11 +316,11 @@ describe('Matrix', () => {
});
it('should throw when trying to add matrices of different shape', () => {
expect(() => mtrx.add([[0]], [[[0]]])).toThrowError(
expect(() => mtrx.add([[0]], [[[0]]])).toThrow(
'Matrices have different dimensions',
);
expect(() => mtrx.add([[0]], [[0, 0]])).toThrowError(
expect(() => mtrx.add([[0]], [[0, 0]])).toThrow(
'Matrices have different shapes',
);
});
@@ -380,11 +380,11 @@ describe('Matrix', () => {
});
it('should throw when trying to multiply matrices element-wise of different shape', () => {
expect(() => mtrx.mul([[0]], [[[0]]])).toThrowError(
expect(() => mtrx.mul([[0]], [[[0]]])).toThrow(
'Matrices have different dimensions',
);
expect(() => mtrx.mul([[0]], [[0, 0]])).toThrowError(
expect(() => mtrx.mul([[0]], [[0, 0]])).toThrow(
'Matrices have different shapes',
);
});
@@ -444,11 +444,11 @@ describe('Matrix', () => {
});
it('should throw when trying to subtract matrices element-wise of different shape', () => {
expect(() => mtrx.sub([[0]], [[[0]]])).toThrowError(
expect(() => mtrx.sub([[0]], [[[0]]])).toThrow(
'Matrices have different dimensions',
);
expect(() => mtrx.sub([[0]], [[0, 0]])).toThrowError(
expect(() => mtrx.sub([[0]], [[0, 0]])).toThrow(
'Matrices have different shapes',
);
});

View File

@@ -4,13 +4,13 @@ describe('kMeans', () => {
it('should throw an error on invalid data', () => {
expect(() => {
KMeans();
}).toThrowError('The data is empty');
}).toThrow('The data is empty');
});
it('should throw an error on inconsistent data', () => {
expect(() => {
KMeans([[1, 2], [1]], 2);
}).toThrowError('Matrices have different shapes');
}).toThrow('Matrices have different shapes');
});
it('should find the nearest neighbour', () => {

View File

@@ -4,28 +4,28 @@ describe('kNN', () => {
it('should throw an error on invalid data', () => {
expect(() => {
kNN();
}).toThrowError('Either dataSet or labels or toClassify were not set');
}).toThrow('Either dataSet or labels or toClassify were not set');
});
it('should throw an error on invalid labels', () => {
const noLabels = () => {
kNN([[1, 1]]);
};
expect(noLabels).toThrowError('Either dataSet or labels or toClassify were not set');
expect(noLabels).toThrow('Either dataSet or labels or toClassify were not set');
});
it('should throw an error on not giving classification vector', () => {
const noClassification = () => {
kNN([[1, 1]], [1]);
};
expect(noClassification).toThrowError('Either dataSet or labels or toClassify were not set');
expect(noClassification).toThrow('Either dataSet or labels or toClassify were not set');
});
it('should throw an error on not giving classification vector', () => {
const inconsistent = () => {
kNN([[1, 1]], [1], [1]);
};
expect(inconsistent).toThrowError('Matrices have different shapes');
expect(inconsistent).toThrow('Matrices have different shapes');
});
it('should find the nearest neighbour', () => {

View File

@@ -6,7 +6,7 @@ describe('hammingDistance', () => {
hammingDistance('a', 'aa');
};
expect(compareStringsOfDifferentLength).toThrowError();
expect(compareStringsOfDifferentLength).toThrow();
});
it('should calculate difference between two strings', () => {

View File

@@ -276,7 +276,7 @@ describe('Graph', () => {
graph.deleteEdge(edgeBC);
}
expect(deleteNotExistingEdge).toThrowError();
expect(deleteNotExistingEdge).toThrow();
});
it('should be possible to reverse graph', () => {

View File

@@ -105,10 +105,10 @@ describe('FenwickTree', () => {
tree.queryRange(3, 2);
};
expect(increaseAtInvalidLowIndex).toThrowError();
expect(increaseAtInvalidHighIndex).toThrowError();
expect(queryInvalidLowIndex).toThrowError();
expect(queryInvalidHighIndex).toThrowError();
expect(rangeQueryInvalidIndex).toThrowError();
expect(increaseAtInvalidLowIndex).toThrow();
expect(increaseAtInvalidHighIndex).toThrow();
expect(queryInvalidLowIndex).toThrow();
expect(queryInvalidHighIndex).toThrow();
expect(rangeQueryInvalidIndex).toThrow();
});
});

View File

@@ -319,6 +319,6 @@ describe('RedBlackTree', () => {
tree.remove(1);
};
expect(removeNodeFromRedBlackTree).toThrowError();
expect(removeNodeFromRedBlackTree).toThrow();
});
});