diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-13 22:22:46 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2019-11-21 08:29:27 +0300 |
commit | 21dd6019ecb8134e2b6af74ccc557cab8bc75413 (patch) | |
tree | c292323e66da6adf961e127560fafc7f95dadcac /src/node_buffer.h | |
parent | 2e43686c5a21701a3a85171906e010aadefeb1ad (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 |