diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-13 22:22:46 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-19 16:02:22 +0300 |
commit | e5d3c8121dd0bcc4dbf52c7b3a0521e359363a05 (patch) | |
tree | 9e7fac09163e14246056bc64228388e78c45e874 /src/node_buffer.h | |
parent | 6cb8e4b12cd16ae8ed126f98458efb78312cabf6 (diff) |
src: expose ArrayBuffer version of Buffer::New()
This can be useful to create `Buffer` instances for already-existing
`ArrayBuffer`s, e.g. ones created manually from a backing store
with a free callback (of which our variant in the public API has
some limitations).
PR-URL: https://github.com/nodejs/node/pull/30476
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_buffer.h')
-rw-r--r-- | src/node_buffer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h index 122afc37709..11010017ce0 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -65,6 +65,12 @@ NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, char* data, size_t len); +// Creates a Buffer instance over an existing ArrayBuffer. +NODE_EXTERN v8::MaybeLocal<v8::Uint8Array> New(v8::Isolate* isolate, + v8::Local<v8::ArrayBuffer> ab, + size_t byte_offset, + size_t length); + // This is verbose to be explicit with inline commenting static inline bool IsWithinBounds(size_t off, size_t len, size_t max) { // Asking to seek too far into the buffer |