The bridge has a few features we should highlight:
Go method names are converted from Pascal to Camel case when accessed in JS. For example, IsGreater becomes isGreater.
Go field names convert from Pascal to Snake case. For example, the struct field ComparisonResult string becomes comparison_result in JS.
Field names may be explicit using js struct tags. For example, declaring the field as ComparisonResult string `js:"result"` or hiding from JS using `js:"-"`.
Type conversion and native constructors
The preceding snippet also demonstrates the native constructors feature from goja, where methods can become JS constructors. Methods with this signature can create Comparator instances in JS with new compare.Comparator(). While this is more idiomatic to JS, it still has the benefit of receiving the goja.Runtime.