Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new function assertStringify() #262

Closed
samchon opened this issue Oct 24, 2022 · 1 comment
Closed

Add a new function assertStringify() #262

samchon opened this issue Oct 24, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@samchon
Copy link
Owner

samchon commented Oct 24, 2022

export function assertStringify<T>(input: T): string;
export function createAssertStringify<T>(): (input: T) => string;

assertStringify() is a new function combined assertType() and stringify().

When it converts an input value to JSON string, its type would be automatically validated and if the input value is not following the type T, TypeGuardError exception would be thrown. I think this function would be much useful than TSON.stringify() and it would be faster than JSON.stringify() even containing the validation process.

@samchon samchon added the enhancement New feature or request label Oct 24, 2022
@samchon samchon self-assigned this Oct 24, 2022
@samchon samchon changed the title New functions assertStringify() and createAssertStringify() Add a new function assertStringify() Oct 24, 2022
@samchon
Copy link
Owner Author

samchon commented Oct 24, 2022

Conversion speed of TSON.assertStringify() measured in Intel i5-1135g7 Surface Pro 8.

Not optimizied yet, but soon. Therefore, conversion speed would be boosted up more.

image

samchon added a commit that referenced this issue Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant