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 JS functions for encoding/decoding byte arrays from and to strings #5902

Merged
merged 7 commits into from
Aug 14, 2024

Conversation

sfmskywalker
Copy link
Member

@sfmskywalker sfmskywalker commented Aug 14, 2024

This PR introduces JavaScript functions to handle encoding and decoding of byte arrays to and from strings. The encoding converts a byte array into a string, and the decoding function does the reverse, converting a string back into a byte array. These utility functions will be useful for scenarios where byte arrays need to be represented as strings for storage or transmission and then restored to their original byte form.


This change is Reviewable

Added several new handlers for configuring the JavaScript engine with common types, functions, variable accessors, and input/output accessors. Refactored the JintJavaScriptEvaluator for better clarity and modularity by breaking down configuration steps into separate methods. Also replaced `IsInsideCompositeActivity` with `IsContainedWithinCompositeActivity` for better semantic consistency.
Updated CommonTypeDefinitionProvider, VariableTypeDefinitionProvider, and ActivityOutputFunctionsDefinitionProvider to use primary constructors for dependency injection. This change reduces redundancy and simplifies the code structure for better readability and maintainability.
Introduced functions for converting bytes to/from strings and Base64. Updated CommonFunctionsDefinitionProvider and ConfigureEngineWithCommonFunctions to incorporate these new functions. This enhances the JavaScript engine's ability to handle byte array manipulations.
Introduce integration tests to verify byte array to string, string to byte array, byte array to Base64, and Base64 to byte array conversions using JavaScript functions. Ensure accurate transformation of data within different encoding scenarios.
Updated comment summaries in four handler classes to provide clear and concise descriptions of their purpose. This helps improve code readability and understanding for future developers.
Merged the variable accessor logic into the input/output handler and renamed the class to reflect its broader functionality. This consolidation ensures the accessors are registered in the right order.
Introduced `stringToBase64` and `stringFromBase64` functions to handle base64 encoding and decoding of strings. Updated corresponding provider, handler, and added tests to ensure functionality.
@sfmskywalker sfmskywalker merged commit 5f11026 into patch/3.2.x Aug 14, 2024
3 checks passed
@sfmskywalker sfmskywalker deleted the feat/5901 branch August 14, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Add JS Functions and Activities for Encoding/Decoding Bytes and Base64
2 participants