js-xdr icon indicating copy to clipboard operation
js-xdr copied to clipboard

Add `valueOf` support to XDR types.

Open Shaptic opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. It is very convenient to be able to use XDR types that correlate to a native type in an inline, convenient way. For example, you could use Hyper inline with arithmetic operations, e.g.

let increment = new Hyper(1234n) + 1n;

Describe the solution you'd like valueOf() methods added to each XDR primitive type we support.

Describe alternatives you've considered Each type has a way to access its raw, underlying value, but this is a little jankier.

Additional context See @paulbellamy's comment here: https://github.com/stellar/dts-xdr/pull/6#discussion_r1236791838.

Shaptic avatar Jun 21 '23 16:06 Shaptic