-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement bin and int64 templates for Uint8Array and bigint generation in TemplateJson #7
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
Conversation
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
bin templates in TemplateJson
streamich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Also introduce
int64template, which is similar tointtemplate, but generates JavaScriptbigintnumbers. - When done make sure to run
yarn format:fixand fixyarn lintissues.
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Implemented the
The implementation follows the same pattern as the existing |
streamich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test fails with:
FAIL src/structured/__tests__/TemplateJson.spec.ts
● Test suite failed to run
TypeError: Do not know how to serialize a BigInt
at stringify (<anonymous>)
at messageParent (node_modules/jest-worker/build/workers/messageParent.js:29:19)
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Fixed the BigInt serialization issue in Jest tests. The problem was that Jest worker processes can't serialize BigInt values when communicating test results between processes. Changed the test assertions to convert BigInt values to strings using |
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR adds support for generating binary data and 64-bit integers using new template types in
TemplateJson.New Template Types
BinTemplate
The
BinTemplategeneratesUint8Arraydata with configurable length and octet value ranges:Int64Template
The
Int64Templategenerates JavaScriptbigintnumbers with configurable ranges:Usage Examples
Implementation Details
int64utility function for bigint random generationTemplateNodeunion type andTemplateShorthandto include both 'bin' and 'int64'generateBinandgenerateInt64methods withmaxNodeslimit supportBigInt()constructor instead of literalsTesting
Added comprehensive test coverage for both template types including:
maxNodeslimitsAll existing tests continue to pass, ensuring backward compatibility.
Fixes #6.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.