mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Upgrade dependencies and fix ESLint issues.
This commit is contained in:
@@ -244,7 +244,7 @@ export default class FourierTester {
|
||||
const { input, output: expectedOutput } = testCase;
|
||||
|
||||
// Try to split input signal into sequence of pure sinusoids.
|
||||
const formattedInput = input.map(sample => sample.amplitude);
|
||||
const formattedInput = input.map((sample) => sample.amplitude);
|
||||
const currentOutput = fourierTransform(formattedInput);
|
||||
|
||||
// Check the signal has been split into proper amount of sub-signals.
|
||||
|
||||
@@ -46,8 +46,8 @@ export default function fastFourierTransform(inputData, inverse = false) {
|
||||
for (let blockLength = 2; blockLength <= N; blockLength *= 2) {
|
||||
const imaginarySign = inverse ? -1 : 1;
|
||||
const phaseStep = new ComplexNumber({
|
||||
re: Math.cos(2 * Math.PI / blockLength),
|
||||
im: imaginarySign * Math.sin(2 * Math.PI / blockLength),
|
||||
re: Math.cos((2 * Math.PI) / blockLength),
|
||||
im: imaginarySign * Math.sin((2 * Math.PI) / blockLength),
|
||||
});
|
||||
|
||||
for (let blockStart = 0; blockStart < N; blockStart += blockLength) {
|
||||
|
||||
@@ -9,7 +9,7 @@ export default function pascalTriangle(lineNumber) {
|
||||
|
||||
for (let numIndex = 1; numIndex < currentLineSize; numIndex += 1) {
|
||||
// See explanation of this formula in README.
|
||||
currentLine[numIndex] = currentLine[numIndex - 1] * (lineNumber - numIndex + 1) / numIndex;
|
||||
currentLine[numIndex] = (currentLine[numIndex - 1] * (lineNumber - numIndex + 1)) / numIndex;
|
||||
}
|
||||
|
||||
return currentLine;
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('degreeToRadian', () => {
|
||||
expect(degreeToRadian(45)).toBe(Math.PI / 4);
|
||||
expect(degreeToRadian(90)).toBe(Math.PI / 2);
|
||||
expect(degreeToRadian(180)).toBe(Math.PI);
|
||||
expect(degreeToRadian(270)).toBe(3 * Math.PI / 2);
|
||||
expect(degreeToRadian(270)).toBe((3 * Math.PI) / 2);
|
||||
expect(degreeToRadian(360)).toBe(2 * Math.PI);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('radianToDegree', () => {
|
||||
expect(radianToDegree(Math.PI / 4)).toBe(45);
|
||||
expect(radianToDegree(Math.PI / 2)).toBe(90);
|
||||
expect(radianToDegree(Math.PI)).toBe(180);
|
||||
expect(radianToDegree(3 * Math.PI / 2)).toBe(270);
|
||||
expect(radianToDegree((3 * Math.PI) / 2)).toBe(270);
|
||||
expect(radianToDegree(2 * Math.PI)).toBe(360);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user