mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Upgrade package dependencies
This commit is contained in:
committed by
Oleksii Trekhleb
parent
024884517f
commit
115e428168
1
.husky/.gitignore
vendored
1
.husky/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
_
|
|
||||||
@@ -1,5 +1 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
npm run lint
|
npm run lint
|
||||||
# npm run test
|
|
||||||
|
|||||||
3313
package-lock.json
generated
3313
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -32,19 +32,19 @@
|
|||||||
"test": "jest",
|
"test": "jest",
|
||||||
"coverage": "npm run test -- --coverage",
|
"coverage": "npm run test -- --coverage",
|
||||||
"ci": "npm run lint && npm run coverage",
|
"ci": "npm run lint && npm run coverage",
|
||||||
"prepare": "husky install"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "7.20.7",
|
"@babel/cli": "^7.28.6",
|
||||||
"@babel/preset-env": "7.20.2",
|
"@babel/preset-env": "^7.29.0",
|
||||||
"@types/jest": "29.4.0",
|
"@types/jest": "^30.0.0",
|
||||||
"eslint": "8.33.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-airbnb": "19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-plugin-import": "2.27.5",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest": "27.2.1",
|
"eslint-plugin-jest": "^27.9.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"husky": "8.0.3",
|
"husky": "^9.1.7",
|
||||||
"jest": "29.4.1",
|
"jest": "^30.2.0",
|
||||||
"pngjs": "^7.0.0"
|
"pngjs": "^7.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { hillCipherEncrypt, hillCipherDecrypt } from '../hillCipher';
|
|||||||
|
|
||||||
describe('hillCipher', () => {
|
describe('hillCipher', () => {
|
||||||
it('should throw an exception when trying to decipher', () => {
|
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', () => {
|
it('should throw an error when message or keyString contains none letter character', () => {
|
||||||
@@ -12,10 +12,10 @@ describe('hillCipher', () => {
|
|||||||
const invalidCharacterInKeyString = () => {
|
const invalidCharacterInKeyString = () => {
|
||||||
hillCipherEncrypt('hello', 'hel12world');
|
hillCipherEncrypt('hello', 'hel12world');
|
||||||
};
|
};
|
||||||
expect(invalidCharacterInMessage).toThrowError(
|
expect(invalidCharacterInMessage).toThrow(
|
||||||
'The message and key string can only contain letters',
|
'The message and key string can only contain letters',
|
||||||
);
|
);
|
||||||
expect(invalidCharacterInKeyString).toThrowError(
|
expect(invalidCharacterInKeyString).toThrow(
|
||||||
'The message and key string can only contain letters',
|
'The message and key string can only contain letters',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -24,7 +24,7 @@ describe('hillCipher', () => {
|
|||||||
const invalidLengthOfKeyString = () => {
|
const invalidLengthOfKeyString = () => {
|
||||||
hillCipherEncrypt('ab', 'ab');
|
hillCipherEncrypt('ab', 'ab');
|
||||||
};
|
};
|
||||||
expect(invalidLengthOfKeyString).toThrowError(
|
expect(invalidLengthOfKeyString).toThrow(
|
||||||
'Invalid key string length. The square root of the key string must be an integer',
|
'Invalid key string length. The square root of the key string must be an integer',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -33,7 +33,7 @@ describe('hillCipher', () => {
|
|||||||
const invalidLengthOfKeyString = () => {
|
const invalidLengthOfKeyString = () => {
|
||||||
hillCipherEncrypt('ab', 'aaabbbccc');
|
hillCipherEncrypt('ab', 'aaabbbccc');
|
||||||
};
|
};
|
||||||
expect(invalidLengthOfKeyString).toThrowError(
|
expect(invalidLengthOfKeyString).toThrow(
|
||||||
'Invalid key string length. The key length must be a square of message length',
|
'Invalid key string length. The key length must be a square of message length',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe('eulerianPath', () => {
|
|||||||
eulerianPath(graph);
|
eulerianPath(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(findEulerianPathInNotEulerianGraph).toThrowError();
|
expect(findEulerianPathInNotEulerianGraph).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find Eulerian Circuit in graph', () => {
|
it('should find Eulerian Circuit in graph', () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('kruskal', () => {
|
|||||||
kruskal(graph);
|
kruskal(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(applyPrimToDirectedGraph).toThrowError();
|
expect(applyPrimToDirectedGraph).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find minimum spanning tree', () => {
|
it('should find minimum spanning tree', () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('prim', () => {
|
|||||||
prim(graph);
|
prim(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(applyPrimToDirectedGraph).toThrowError();
|
expect(applyPrimToDirectedGraph).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find minimum spanning tree', () => {
|
it('should find minimum spanning tree', () => {
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ describe('euclideanDistance', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error in case if two matrices are of different shapes', () => {
|
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',
|
'Matrices have different dimensions',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() => euclideanDistance([[1]], [[2, 3]])).toThrowError(
|
expect(() => euclideanDistance([[1]], [[2, 3]])).toThrow(
|
||||||
'Matrices have different shapes',
|
'Matrices have different shapes',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ describe('Matrix', () => {
|
|||||||
it('should throw when trying to add matrices of invalid shapes', () => {
|
it('should throw when trying to add matrices of invalid shapes', () => {
|
||||||
expect(
|
expect(
|
||||||
() => mtrx.dot([0], [1]),
|
() => mtrx.dot([0], [1]),
|
||||||
).toThrowError('Invalid matrix format');
|
).toThrow('Invalid matrix format');
|
||||||
expect(
|
expect(
|
||||||
() => mtrx.dot([[0]], [1]),
|
() => mtrx.dot([[0]], [1]),
|
||||||
).toThrowError('Invalid matrix format');
|
).toThrow('Invalid matrix format');
|
||||||
expect(
|
expect(
|
||||||
() => mtrx.dot([[[0]]], [[1]]),
|
() => mtrx.dot([[[0]]], [[1]]),
|
||||||
).toThrowError('Matrix is not of 2D shape');
|
).toThrow('Matrix is not of 2D shape');
|
||||||
expect(
|
expect(
|
||||||
() => mtrx.dot([[0]], [[1], [2]]),
|
() => mtrx.dot([[0]], [[1], [2]]),
|
||||||
).toThrowError('Matrices have incompatible shape for multiplication');
|
).toThrow('Matrices have incompatible shape for multiplication');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should calculate matrices dimensions', () => {
|
it('should calculate matrices dimensions', () => {
|
||||||
@@ -252,7 +252,7 @@ describe('Matrix', () => {
|
|||||||
it('should throw when trying to transpose non 2D matrix', () => {
|
it('should throw when trying to transpose non 2D matrix', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
mtrx.t([[[1]]]);
|
mtrx.t([[[1]]]);
|
||||||
}).toThrowError('Matrix is not of 2D shape');
|
}).toThrow('Matrix is not of 2D shape');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add two matrices', () => {
|
it('should add two matrices', () => {
|
||||||
@@ -316,11 +316,11 @@ describe('Matrix', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when trying to add matrices of different shape', () => {
|
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',
|
'Matrices have different dimensions',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() => mtrx.add([[0]], [[0, 0]])).toThrowError(
|
expect(() => mtrx.add([[0]], [[0, 0]])).toThrow(
|
||||||
'Matrices have different shapes',
|
'Matrices have different shapes',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -380,11 +380,11 @@ describe('Matrix', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when trying to multiply matrices element-wise of different shape', () => {
|
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',
|
'Matrices have different dimensions',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() => mtrx.mul([[0]], [[0, 0]])).toThrowError(
|
expect(() => mtrx.mul([[0]], [[0, 0]])).toThrow(
|
||||||
'Matrices have different shapes',
|
'Matrices have different shapes',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -444,11 +444,11 @@ describe('Matrix', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when trying to subtract matrices element-wise of different shape', () => {
|
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',
|
'Matrices have different dimensions',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() => mtrx.sub([[0]], [[0, 0]])).toThrowError(
|
expect(() => mtrx.sub([[0]], [[0, 0]])).toThrow(
|
||||||
'Matrices have different shapes',
|
'Matrices have different shapes',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ describe('kMeans', () => {
|
|||||||
it('should throw an error on invalid data', () => {
|
it('should throw an error on invalid data', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
KMeans();
|
KMeans();
|
||||||
}).toThrowError('The data is empty');
|
}).toThrow('The data is empty');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error on inconsistent data', () => {
|
it('should throw an error on inconsistent data', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
KMeans([[1, 2], [1]], 2);
|
KMeans([[1, 2], [1]], 2);
|
||||||
}).toThrowError('Matrices have different shapes');
|
}).toThrow('Matrices have different shapes');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find the nearest neighbour', () => {
|
it('should find the nearest neighbour', () => {
|
||||||
|
|||||||
@@ -4,28 +4,28 @@ describe('kNN', () => {
|
|||||||
it('should throw an error on invalid data', () => {
|
it('should throw an error on invalid data', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
kNN();
|
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', () => {
|
it('should throw an error on invalid labels', () => {
|
||||||
const noLabels = () => {
|
const noLabels = () => {
|
||||||
kNN([[1, 1]]);
|
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', () => {
|
it('should throw an error on not giving classification vector', () => {
|
||||||
const noClassification = () => {
|
const noClassification = () => {
|
||||||
kNN([[1, 1]], [1]);
|
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', () => {
|
it('should throw an error on not giving classification vector', () => {
|
||||||
const inconsistent = () => {
|
const inconsistent = () => {
|
||||||
kNN([[1, 1]], [1], [1]);
|
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', () => {
|
it('should find the nearest neighbour', () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe('hammingDistance', () => {
|
|||||||
hammingDistance('a', 'aa');
|
hammingDistance('a', 'aa');
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(compareStringsOfDifferentLength).toThrowError();
|
expect(compareStringsOfDifferentLength).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should calculate difference between two strings', () => {
|
it('should calculate difference between two strings', () => {
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ describe('Graph', () => {
|
|||||||
graph.deleteEdge(edgeBC);
|
graph.deleteEdge(edgeBC);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(deleteNotExistingEdge).toThrowError();
|
expect(deleteNotExistingEdge).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be possible to reverse graph', () => {
|
it('should be possible to reverse graph', () => {
|
||||||
|
|||||||
@@ -105,10 +105,10 @@ describe('FenwickTree', () => {
|
|||||||
tree.queryRange(3, 2);
|
tree.queryRange(3, 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(increaseAtInvalidLowIndex).toThrowError();
|
expect(increaseAtInvalidLowIndex).toThrow();
|
||||||
expect(increaseAtInvalidHighIndex).toThrowError();
|
expect(increaseAtInvalidHighIndex).toThrow();
|
||||||
expect(queryInvalidLowIndex).toThrowError();
|
expect(queryInvalidLowIndex).toThrow();
|
||||||
expect(queryInvalidHighIndex).toThrowError();
|
expect(queryInvalidHighIndex).toThrow();
|
||||||
expect(rangeQueryInvalidIndex).toThrowError();
|
expect(rangeQueryInvalidIndex).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -319,6 +319,6 @@ describe('RedBlackTree', () => {
|
|||||||
tree.remove(1);
|
tree.remove(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(removeNodeFromRedBlackTree).toThrowError();
|
expect(removeNodeFromRedBlackTree).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user