Skip to content

Commit

Permalink
Make Buffer extend Uint8Array
Browse files Browse the repository at this point in the history
Make Buffer extend Uint8Array instead of directly extending Object

PR-URL: nodejs/node-addon-api#188
Fixes: nodejs/node-addon-api#109
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
kevindavies8 committed Nov 23, 2017
1 parent 4bec321 commit 8668318
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1524,17 +1524,17 @@ inline Buffer<T> Buffer<T>::Copy(napi_env env, const T* data, size_t length) {
}

template <typename T>
inline Buffer<T>::Buffer() : Object(), _length(0), _data(nullptr) {
inline Buffer<T>::Buffer() : Uint8Array(), _length(0), _data(nullptr) {
}

template <typename T>
inline Buffer<T>::Buffer(napi_env env, napi_value value)
: Object(env, value), _length(0), _data(nullptr) {
: Uint8Array(env, value), _length(0), _data(nullptr) {
}

template <typename T>
inline Buffer<T>::Buffer(napi_env env, napi_value value, size_t length, T* data)
: Object(env, value), _length(length), _data(data) {
: Uint8Array(env, value), _length(length), _data(data) {
}

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ namespace Napi {
};

template <typename T>
class Buffer : public Object {
class Buffer : public Uint8Array {
public:
static Buffer<T> New(napi_env env, size_t length);
static Buffer<T> New(napi_env env, T* data, size_t length);
Expand Down

0 comments on commit 8668318

Please sign in to comment.