-
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.
* Add typia * For lint * Add new line * typia on npm commands * Understood what parseSafe is * More simple parseSafe * Update README.md - add typia * Change `ITransformOptions.undefined` value * Upgrade typia version * Upgrade typia version * Update typia again * block undefined value
- Loading branch information
Showing
12 changed files
with
114 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
docs/dist | ||
cases/spectypes/build | ||
cases/ts-runtime-checks/build | ||
case/typia/build |
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ export const cases = [ | |
'ts-utils', | ||
'tson', | ||
'typeofweb-schema', | ||
'typia', | ||
'valita', | ||
'vality', | ||
'yup', | ||
|
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,7 @@ | ||
import { parseSafe, parseStrict, assertLoose, assertStrict } from './build'; | ||
import { addCase } from '../../benchmarks'; | ||
|
||
addCase('typia', 'parseSafe', parseSafe); | ||
addCase('typia', 'parseStrict', parseStrict); | ||
addCase('typia', 'assertStrict', assertStrict); | ||
addCase('typia', 'assertLoose', assertLoose); |
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,39 @@ | ||
import typia from 'typia'; | ||
|
||
interface ToBeChecked { | ||
number: number; | ||
negNumber: number; | ||
maxNumber: number; | ||
string: string; | ||
longString: string; | ||
boolean: boolean; | ||
deeplyNested: { | ||
foo: string; | ||
num: number; | ||
bool: boolean; | ||
}; | ||
} | ||
|
||
const is = typia.createIs<ToBeChecked>(); | ||
const equals = typia.createEquals<ToBeChecked>(); | ||
const stringify = typia.createStringify<ToBeChecked>(); | ||
|
||
export function assertLoose(input: unknown): boolean { | ||
if (!is(input)) throw new Error('wrong type.'); | ||
return true; | ||
} | ||
|
||
export function assertStrict(input: unknown): boolean { | ||
if (!equals(input)) throw new Error('wrong type.'); | ||
return true; | ||
} | ||
|
||
export function parseStrict(input: unknown): ToBeChecked { | ||
if (!equals(input)) throw new Error('wrong type.'); | ||
return input; | ||
} | ||
|
||
export function parseSafe(input: unknown): ToBeChecked { | ||
if (!is(input)) throw new Error('wrong type.'); | ||
return JSON.parse(stringify(input)); | ||
} |
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,16 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "build", | ||
"strict": true, | ||
"plugins": [ | ||
{ | ||
"transform": "typia/lib/transform", | ||
"undefined": false, | ||
} | ||
] | ||
}, | ||
"include": ["src/index.ts"] | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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