Removed unneccessary setting of length of arraybuffer #7
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix-arraybuffer-set-length"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@khankuan The underlying buffer in the decode function is reused between calls to avoid numerous allocations of small buffers. That particular length assignment is important since it is used in the toString call to determine which bytes of the buffer are used in the encoding (the default behavior of the toString function uses the buffer's length field as the end index).
It might be preferable to explicitly specify the end in the function call itself, like
mdb.toString('ucs2', 0, 2 * len);
, but somewhere the length has to be specifiedHmm ic. The problem occurred when I was in strict mode. It says that the buffer length is a read-only property (at least on chrome). When I removed that line, the library works as normal for my particular use case.
@khankuan do you have a small example? That particular line should not be triggered in Chrome because the
Buffer
is not generally available and the global check should prevent that logic from being called in the first placeThis should be fixed in version 1.4.0
Pull request closed