-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: render 및 state에 deepEqual 체크 로직 추가
- Loading branch information
Showing
8 changed files
with
55 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
import { VNode } from "./type"; | ||
|
||
export const isBooleanTrue = (value: any) => | ||
typeof value === "boolean" && value; | ||
|
||
export const isNumberZero = (value: any) => value === 0; | ||
|
||
export const stringifyWhen = (value: any) => | ||
typeof value === "string" || typeof value === "number"; | ||
|
||
export const returnEmptyStringWhen = (value: any) => | ||
!value || isBooleanTrue(value); | ||
|
||
export const isStringOrNum = (value: any): value is string | number => | ||
typeof value === "string" || typeof value === "number"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export const deepEqual = (obj1: any, obj2: any) => { | ||
if (obj1 === obj2) return true; | ||
|
||
if ( | ||
typeof obj1 !== "object" || | ||
obj1 === null || | ||
typeof obj2 !== "object" || | ||
obj2 === null | ||
) { | ||
return false; | ||
} | ||
|
||
const keys1 = Object.keys(obj1); | ||
const keys2 = Object.keys(obj2); | ||
|
||
if (keys1.length !== keys2.length) return false; | ||
|
||
for (const key of keys1) { | ||
if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./eventUtils"; | ||
export * from "./timeUtils"; | ||
export * from "./deepEqual"; |