-
-
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 <[email protected]>
bin
templates in TemplateJson
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
int64
template, which is similar toint
template, but generates JavaScriptbigint
numbers. - When done make sure to run
yarn format:fix
and fixyarn lint
issues.
Co-authored-by: streamich <[email protected]>
Co-authored-by: streamich <[email protected]>
Implemented the
The implementation follows the same pattern as the existing |
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 <[email protected]>
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
BinTemplate
generatesUint8Array
data with configurable length and octet value ranges:Int64Template
The
Int64Template
generates JavaScriptbigint
numbers with configurable ranges:Usage Examples
Implementation Details
int64
utility function for bigint random generationTemplateNode
union type andTemplateShorthand
to include both 'bin' and 'int64'generateBin
andgenerateInt64
methods withmaxNodes
limit supportBigInt()
constructor instead of literalsTesting
Added comprehensive test coverage for both template types including:
maxNodes
limitsAll 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.