Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Add toBuffer() method to Address, make toBuffer() function convert TransformableToBuffer #277

Merged
merged 7 commits into from
Oct 7, 2020

Conversation

ryanio
Copy link
Contributor

@ryanio ryanio commented Sep 29, 2020

This PR adds a toBuffer() method to Address, and makes the exported toBuffer() function additionally handle if the object has a toBuffer() method.

This work was motivated by @jochem-brouwer's work in the block library refactoring (thread here).

@coveralls
Copy link

coveralls commented Sep 29, 2020

Coverage Status

Coverage increased (+0.004%) to 99.532% when pulling 45512f8 on tobuffer-improvements into c5dca47 on master.

src/bytes.ts Outdated Show resolved Hide resolved
@holgerd77
Copy link
Member

Rebased this and moved the interfaces mentioned (so: TransformableToArray and TransformableToBuffer) to ./types. Will merge once tests pass.

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, will merge and prepare a subsequent release PR.

return Buffer.from(v.toBuffer())
}

throw new Error('invalid type')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this refactored and simplified code of the toBuffer method, also highly valuable to have proper input types here now. 😍

@holgerd77 holgerd77 merged commit c0798ed into master Oct 7, 2020
@holgerd77 holgerd77 deleted the tobuffer-improvements branch October 7, 2020 14:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants