emn178 / js-sha3

A simple SHA-3 / Keccak hash function for JavaScript supports UTF-8 encoding.
MIT License
350 stars 85 forks source link

refactor: simplify formatMessage internal logic #34

Closed legobeat closed 1 year ago

legobeat commented 1 year ago

This reduces the nesting and branching-complexity of formatMessage in an attempt to make it more readable.

Also changes formatMessage to return [message:string, isString:bool] rather than [message:string, notString:bool] to remove the double-negation inside encodeString and update methods.

Based on and includes:

emn178 commented 1 year ago

merge this PR and close previous?

legobeat commented 1 year ago

@emn178 Thanks for following up! Your call if you prefer them to be merged individually or as one, thought I'd give you the option to separate the functional change from the refactor :)