andreachild commented on code in PR #3194:
URL: https://github.com/apache/tinkerpop/pull/3194#discussion_r2310707825
##########
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js:
##########
@@ -79,10 +79,19 @@ class Edge extends Element {
this.inV = inV;
this.properties = {};
if (properties) {
- const keys = Object.keys(properties);
- for (let i = 0; i < keys.length; i++) {
- const k = keys[i];
- this.properties[k] = properties[k].value;
+ if (Array.isArray(properties)) {
+ // Handle array of Property objects
+ for (let i = 0; i < properties.length; i++) {
+ const prop = properties[i];
+ this.properties[prop.key] = prop.value;
+ }
+ } else {
+ // Handle object format as before
+ const keys = Object.keys(properties);
+ for (let i = 0; i < keys.length; i++) {
+ const k = keys[i];
+ this.properties[k] = properties[k].value;
+ }
Review Comment:
Nit: can simplify
```suggestion
if (Array.isArray(properties)) {
// Handle array of Property objects
properties.forEach(prop => this.properties[prop.key] = prop.value);
} else {
// Handle object format as before
Object.keys(properties).forEach(k => this.properties[k] =
properties[k].value);
```
Edit: nevermind, linter doesn't like this for some reason
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]