style(middleware-logger): function typo correction + parameter name fix
MODIFY
packages/middleware-logger/src/logger.util.ts
packages/middleware-logger/src/logger.util.ts
@@ -14,16 +14,16 @@ export const filterResponse = (opts: LoggerOptions) => (res: HttpResponse) =>
export const writeToStream = (stream: WriteStream, chunk: string) =>
stream.write(`${chunk}\n\n`);
-export const formatTime = (timeMs: number) =>
- timeMs > 1000
- ? `${timeMs / 1000}s`
- : `${timeMs}ms`;
+export const formatTime = (timeInMms: number) =>
+ timeInMms > 1000
+ ? `${timeInMms / 1000}s`
+ : `${timeInMms}ms`;
-export const getTimeDifferencIneMs = (startTime: Date): number =>
+export const getTimeDifferenceInMs = (startTime: Date): number =>
new Date().getTime() - startTime.getTime();
export const factorizeTime = (timestamp: number) =>
compose(
formatTime,
- getTimeDifferencIneMs
+ getTimeDifferenceInMs
)(new Date(timestamp));

MODIFY
packages/middleware-logger/src/spec/logger.util.spec.ts
packages/middleware-logger/src/spec/logger.util.spec.ts
import { join } from 'path';
import { createWriteStream } from 'fs';
import { HttpResponse } from '@marblejs/core';
-import { formatTime, getTimeDifferencIneMs, filterResponse, isNotSilent, writeToStream } from '../logger.util';
+import { formatTime, getTimeDifferenceInMs, filterResponse, isNotSilent, writeToStream } from '../logger.util';
describe('Logger util', () => {
test('#formatTime formats time to miliseconds or seconds', () => {
@@ -18,13 +18,13 @@ describe('Logger util', () => {
expect(formattedMilisecond).toBe('800ms');
});
- test('#getTimeDifferenceMs returns time difference in miliseconds', () => {
+ test('#getTimeDifferenceInMs returns time difference in miliseconds', () => {
// given
const startTime = new Date(1000);
spyOn(global, 'Date').and.returnValue({ getTime: () => 2000 });
// when
- const timeDifference = getTimeDifferencIneMs(startTime);
+ const timeDifference = getTimeDifferenceInMs(startTime);
// then
expect(timeDifference).toBe(2000 - 1000);

style(middleware-logger): function typo correction + parameter name fix