From c6b28158e96180f90a031a1835129017f0d914ba Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sun, 5 Feb 2023 00:55:33 +0900 Subject: [PATCH] More simple parseSafe --- cases/typia/src/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cases/typia/src/index.ts b/cases/typia/src/index.ts index a42175194..a823029a1 100644 --- a/cases/typia/src/index.ts +++ b/cases/typia/src/index.ts @@ -16,7 +16,7 @@ interface ToBeChecked { const is = typia.createIs(); const equals = typia.createEquals(); -const stringify = typia.createIsStringify(); +const stringify = typia.createStringify(); export function assertLoose(input: unknown): boolean { if (!is(input)) throw new Error('wrong type.'); @@ -34,7 +34,6 @@ export function parseStrict(input: unknown): ToBeChecked { } export function parseSafe(input: unknown): ToBeChecked { - const json: string | null = stringify(input); - if (json === null) throw new Error('wrong type.'); - return JSON.parse(json); + if (!is(input)) throw new Error('wrong type.'); + return JSON.parse(stringify(input)); }