DEV Community

I made 10x faster JSON.stringify() functions, even type safe

Jeongho Nam on October 25, 2022

// FASTER STRINGIFY FUNCTIONS export function stringify<T>(input: T): string; // unsafe but fatest export function assertStringify<T&gt...
Collapse
 
arsalannury profile image
ArsalanNury

i reading document of this package and it is easy to learn . thank you

Collapse
 
dendihandian profile image
Dendi Handian

Gonna read this later

Collapse
 
wadecodez profile image
Wade Zimmerman

So basically this library is faster than the native stringify because it's defining a schema ahead of time?

If so, I'm curious how this would work with applications with large amount of data. Would it slow down the initial page load?

Collapse
 
samchon profile image
Jeongho Nam

Bundle size of typescript-json is extremely small (as it works only in compilation process) and generated code by typescript-json not such small. Therefore, I think it does not effect on initial page loading unless you've defined typescript-json function calling code over thousands of times.

Collapse
 
vineyrawat profile image
Viney Rawat

Good post

Collapse
 
sanjeevkse profile image
sanjeev shetty

Gonna read this later

Collapse
 
rida profile image
Rida F'kih

Interesting, are you using TypeScript transformers to generate the validation objects during compilation?

Collapse
 
samchon profile image
Jeongho Nam

Yes, utilizing ttypescript

Collapse
 
glowreeyah profile image
Gloria Asuquo

This is so educative

Collapse
 
samchon profile image
Jeongho Nam

As I've promised, wrote an article introducing how to use typia in NestJS.

dev.to/samchon/nestia-boost-up-you...

Collapse
 
mrrightp profile image
Right possible

can it be use with normal javascript???

Collapse
 
samchon profile image
Jeongho Nam

Not possible in pure JavaScript. However, detour way like building reusable functions in TypeScript and importing them in JavaScript is possible.

Collapse
 
tienthanhjlw profile image
Nguyễn Tiến Thành

thank you!

Collapse
 
dreamecho100 profile image
DreamEcho100

Can it be use with JavaScript + JSDocs?

Collapse
 
samchon profile image
Jeongho Nam

TypeScript only