Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Use buffer.buffer property #2

Merged
merged 2 commits into from
Dec 28, 2015
Merged

Use buffer.buffer property #2

merged 2 commits into from
Dec 28, 2015

Conversation

dy
Copy link
Contributor

@dy dy commented Dec 27, 2015

From the discussion.

There is a way in node 4.x+ to slice Buffer’s ArrayBuffer instead of copying it per-element. Benchmark shows it is at least three times faster.

@miguelmota

@@ -1,6 +1,13 @@
(function(root) {
var isArrayBufferSupported = (new Buffer(0)).buffer instanceof ArrayBuffer;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also do new Buffer(0) instanceof Uint8Array or Buffer.__proto__ === Uint8Array or (using standardized API) Object.getPrototypeOf(Buffer) === Uint8Array

@miguelmota miguelmota merged commit ed8276a into miguelmota:master Dec 28, 2015
@miguelmota
Copy link
Owner

Makes sense. Merged!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants