Skip to content

Commit

Permalink
reset: 테스트를 통과하는 코드로 수정합니다
Browse files Browse the repository at this point in the history
  • Loading branch information
gmkim716 committed Jan 4, 2025
1 parent a535c57 commit 0580826
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/@lib/equalities/deepEquals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function deepEquals<T>(objA: T, objB: T): boolean {
return keysA.every(
(key) =>
Object.prototype.hasOwnProperty.call(objB, key) &&
deepEquals(objA[key as keyof T], objB[key as keyof T])
deepEquals(objA[key as keyof T], objB[key as keyof T]),
);

// for (const key of keysA) {
Expand Down
2 changes: 1 addition & 1 deletion src/@lib/equalities/shallowEquals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function shallowEquals<T extends object>(objA: T, objB: T): boolean {
(item) =>
Object.prototype.hasOwnProperty.call(objB, item) &&
(objA as { [key: string]: unknown })[item] ===
(objB as { [key: string]: unknown })[item]
(objB as { [key: string]: unknown })[item],
);
// // 4-2. 방식2: for-of 사용
// for (const key of keysA) {
Expand Down
8 changes: 4 additions & 4 deletions src/@lib/hooks/ver1/useItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export const useHandleItem = () => {
items.filter(
(item) =>
item.name.toLowerCase().includes(filter.toLowerCase()) ||
item.category.toLowerCase().includes(filter.toLowerCase())
item.category.toLowerCase().includes(filter.toLowerCase()),
),
[items, filter]
[items, filter],
);

const totalPrice = useMemo(
() => filteredItems.reduce((sum, item) => sum + item.price, 0),
[filteredItems]
[filteredItems],
);

const averagePrice = useMemo(
() => Math.round(totalPrice / filteredItems.length) || 0,
[totalPrice, filteredItems.length]
[totalPrice, filteredItems.length],
);

return {
Expand Down
4 changes: 2 additions & 2 deletions src/@lib/hooks/ver2/useItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function useItem() {
items.filter(
(item) =>
item.name.toLowerCase().includes(filter.toLowerCase()) ||
item.category.toLowerCase().includes(filter.toLowerCase())
item.category.toLowerCase().includes(filter.toLowerCase()),
),
[items, filter]
[items, filter],
);

return {
Expand Down
4 changes: 2 additions & 2 deletions src/@lib/hooks/ver2/usePrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export function usePrice() {

const totalPrice = useMemo(
() => filteredItems.reduce((sum, item) => sum + item.price, 0),
[filteredItems]
[filteredItems],
);

const averagePrice = useMemo(
() => Math.round(totalPrice / filteredItems.length) || 0,
[totalPrice]
[totalPrice],
);

return { totalPrice, averagePrice };
Expand Down

0 comments on commit 0580826

Please sign in to comment.