dionjwa / dionjwa/nodejs-std

haxe.io.Bytes.alloc should initialize the buffer

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
43
Forks
30
PR merge metrics
No merged PRs in 30d

Description

All nodejs docs show that

``` javascript
new Buffer(length);
```

is **uninitialized**

However,

``` javascript
haxe.io.Bytes.alloc(length);
```

returns an initialized (with 0's) buffer in all targets. While I can't seem to find any documentation to support this, the code in the standard haxe.io.Bytes suggests this to be the case

To maintain consistency, probably should do (at about line 266 in haxe/io/Bytes.hx) :

``` javascript
#elseif (nodejs || nodejs_std)
var a = new js.Node.NodeBuffer(length);
a.fill(0, 0, length);
return new Bytes(length,a);
```

instead of

``` javascript
#elseif (nodejs || nodejs_std)
return new Bytes(length,new js.Node.NodeBuffer(length));
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.