Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
proto-expand
Advanced tools
The code in this module is used to preprocess a **process definition** (A.K.A. **Protocol**) and expand it to a flattened format.
The code in this module is used to preprocess a process definition (A.K.A. Protocol) and expand it to a flattened format.
SWAR version 1.x doesn't support arrays
so every value needs to be a scalar.
The current workaround is to expand an array
as a set of scalar values using a postfix number.
So instead of having an array x
you will have n scalars:
x_1 x_2 ... x_n
To be able to do that you need to know n beforehand. This limit the workaround to cases where n is fixed.
This module was created to solve that problem
Given the data to initialize a process in a standard json format, for example:
const initialPayload = {
"a": 10,
"b": "xxx",
"tires": [
{"pressure": 36},
{"pressure": 36},
{"pressure": 40},
{"pressure": 40}
],
"doors": [
{"width": 10},
{"width": 10},
]
}
The data can be transformed in a flatten version of the payload for example:
flattenPayload(initialPayload)
Will return
const result = {
"a": 10,
"b": "xxx",
"pressure_1": 36,
"pressure_2": 36,
"pressure_3": 40,
"pressure_4": 40,
"width_1": 10,
"width_2": 10
};
Also check payload.ts
for additional functions to operate Payloads
As of today a Protocol is just a set of activities each one containing a set of instructions
Appropriate Classes Activity
and Instructions
are created to represent this concepts. A protocol definition is just an Array<Activity>
A simple end to end example of expansion will be like this:
// Extract the `Dimensions` from the `Payload`
const dimensions: Dimensions = extractDimensions(payload)
// Parse a Protocol dedinition (This assume a big string as defined in a proto file today)
const activities: Array<Activity> = parseProtoString("A proto file loaded in an string")
// Expand the variables
const expandedActivities: Array<Activity> = expandAllActivities(activities, dimensions)
// Convert the array back to a big `string`
const bigString = exportToString(expandedActivities)
FAQs
The code in this module is used to manipulate a **process definition** (A.K.A. **Protocol**).
The npm package proto-expand receives a total of 74 weekly downloads. As such, proto-expand popularity was classified as not popular.
We found that proto-expand demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.