add support for node 4.2.0 to 4.4.7 with specific buffer polyfill #665
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enables support for Node 4.3.2 (which I'm stuck with on AWS Lambda).
The
Buffer
object in Node 4.0, 4.1, 4.1, and 4.4 have aBuffer.from
method defined which is inherited fromUint8Array
. The current polyfill only checks iffrom
is present and thefrom
method in these versions accept a typed array as an argument, which doesn't behave nicely.This PR replaces
util.Buffer
with a new object on those node versions and brings compatibility to Node 4.2.0 to 4.4.7. Unfortunately,Buffer
can't be inherited from on 4.0 and 4.1, so this polyfill doesn't work there.Ran tests locally with node 4.3.2 and they all passed and I'm also using this PR to decode protobuf messages in lambda through the static code generation.
Maybe node 4.3.2 should be added to travis to prevent regression?