harttle/liquidjs

Enhance `isComparable` function for full Comparable interface implementation

GuillermoCasalCaro opened this issue ยท 1 comments

Hello, this is my first created issue, if there is something wrong just tell me!

The current implementation of the isComparable function only checks if the equals method is present on the object. This is leading me to issues when I'm using a custom Drop class that casually also has an implementation of equals, but I don't want to make it an implementation of the Comparable interface.

When I use the operators <, >, <=, and >= the class is detected as an implementation of Comparable and tries to execute the related functions. This happens in the operator code.

Proposed Solution

Enhance the isComparable function to check for the complete implementation of the Comparable interface, ensuring that the methods equals, gt, geq, lt, and leq are present on the object.

I made a fork and a PR for this. I will link it right now.

Benefits

This will ensure that objects are properly evaluated and that they will use the proper comparison functions, improving the robustness of the template evaluation for the operators <, >, <=, and >=.

Please let me know if this enhancement is acceptable or if there are any changes or additional considerations I should take into account.

๐ŸŽ‰ This issue has been resolved in version 10.13.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€