Skip to content

only define toBuffer if Buffer is defined#172

Merged
dcousens merged 2 commits intomasterfrom
bufbuf
Nov 30, 2017
Merged

only define toBuffer if Buffer is defined#172
dcousens merged 2 commits intomasterfrom
bufbuf

Conversation

@dcousens
Copy link
Contributor

@dcousens dcousens commented Nov 29, 2017

Alternative to having a run-time check?

Error is more legible too, IMHO.

The existing error:

    if (!val) throw new Error(msg || 'Assertion failed');
              ^
Error: Assertion failed

The new

TypeError: mynum.toBuffer is not a function

Copy link
Owner

@indutny indutny left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants