HaxeFoundation / HaxeFoundation/hxnodejs
Current implementation of hxFromBytes incompatible with Node 4.x
- Dominant language
- Haxe
- Stars
- 177
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
Before `hxFromBytes(foo)` would generate
```js
new Buffer(foo.b.bufferValue)
```
but that changed with HaxeFoundation/hxnodejs@19a1e2b9af60860b0f0b9e0d5f2a933ff12c6031 (and HaxeFoundation/hxnodejs@9b24a891e640beca1bb57dea31800acafe696ebb) to
```js
new Buffer(foo.b.bytes, foo.b.byteOffset, foo.b.byteLength)
```
However, the history of the `new Buffer(arrayBuffer, offset, length)` NodeJS constructor [isn't as linear as one would hope](https://nodejs.org/dist/latest-v8.x/docs/api/buffer.html#buffer_new_buffer_arraybuffer_byteoffset_length):

Since the constructor isn't supported in Node 4.x, the current implementation has the effect of calling `new Buffer(foo.b.bytes)`, making the new buffer point to the _entire_ underlying array buffer of `foo`, that _will also contain data for other buffers_, because of pooling.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.