Closed mcollina closed 7 years ago
Using instanceof
results in a better:
benchThrough2*10000: 5649.387ms
@bmeurer thanks, updated.
The move to using instanceof
will fail for cross-realm Uint8Array
objects (e.g., from iframes or, depending on the setup/Node.js version, different node V8 vm's). Is that a concern?
In contrast, the Object.prototype.toString()
approach supports cross-realm objects.
I do not think so. Considering the cost of using the toString()
approach, I think it's a trade-off that we must accept.
Ideally there'd be an instance type check for Uint8Array
and friends. instanceof
doesn't really check whether the object is an Uint8Array
, but rather if it has a certain prototype, which is obviously realm specific.
Fixes https://github.com/nodejs/readable-stream/issues/302
This is a partial fix.
Node 6.11, using readable-stream 2.2.11:
Node 6.11, using readable-stream 2.3.2:
Node 6.11, using this patch:
I think we can do better.
cc @bmeurer