Skip to content

Conversation

@timsuchanek
Copy link
Contributor

Closes #318

@ronag
Copy link
Member

ronag commented Aug 13, 2020

Could you add a isBuffer in util instead?

function isBuffer (buffer) {
  // See, https://github.com/mcollina/undici/pull/319
  return buffer instanceof Uint8Array || Buffer.isBuffer(buffer)
}

and replace all occurrences of instanceof Uint8Array with it?

@timsuchanek
Copy link
Contributor Author

Yep will do

@timsuchanek
Copy link
Contributor Author

Done

@ronag ronag requested a review from mcollina August 13, 2020 15:13

function isBuffer (buffer) {
// See, https://github.com/mcollina/undici/pull/319
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer)
Copy link
Member

Choose a reason for hiding this comment

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

I'm totally lost on why Buffer.isBuffer would work, but hey.

Copy link
Member

Choose a reason for hiding this comment

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

Related? jestjs/jest#9983

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be enough to do instanceof Uint8Array?
Buffer is a instanceof Uint8Array after all...

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@ronag ronag merged commit 511be84 into nodejs:master Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't work within jest

4 participants