dashd-rpc icon indicating copy to clipboard operation
dashd-rpc copied to clipboard

DH 4: ref+fix: simpler bool check, including 'undefined'

Open coolaj86 opened this issue 11 months ago • 0 comments

Cleaner, easier to read and understand, also handles the case of undefined, rather than throwing an error.

Also corrects the type of getRawTransaction in a backwards-compatible way:

  • arg > 0 preserves the truthiness of values previously marked as int, providing an upgrade path

Should undefined throw?

If throwing an error for undefined is actually the desired behavior, this change can be made:

- return (String(arg).toLowerCase() === 'true' || arg > 0);
+ return (arg.toString().toLowerCase() === 'true' || arg > 0);

coolaj86 avatar Mar 14 '24 05:03 coolaj86