WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@pirxpilot
Copy link

there is no need to check the entity type because Buffer.byteLength works correctly for both String and Buffer
utf8 is the default encoding when entity is a String

this change also make the module compatible with TypedArray entities

see:
https://nodejs.org/api/buffer.html#static-method-bufferbytelengthstring-encoding

there is no need to check the entity type because `Buffer.byteLength`
works correctly for both `String` and `Buffer`
`utf8` is the default encoding when entity is a `String`

this change also make the module compatible with `TypedArray` entities

see:
https://nodejs.org/api/buffer.html#static-method-bufferbytelengthstring-encoding
Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

Thanks @pirxpilot for creating this PR! :)

Currently we support Node.js super legacy versions, like [email protected] and this refactor might not work for that versions (ref) buffer support was added "recently".

But this change can work 💯 for the next major 👍

@pirxpilot
Copy link
Author

Thanks. Makes sense.
In case folks need that info Buffer.byteLength in its modern form has been implemented in node 6.0
There might be a subtle issue with the wrong length being used when etag module gets passed TypedArray but probably with minuscule real world impact.

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