diff options
author | Ouyang Yadong <oyydoibh@gmail.com> | 2018-10-29 14:36:19 +0300 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2018-10-31 17:41:41 +0300 |
commit | 56881b0d952312320ee6a27e40bd553152e11688 (patch) | |
tree | a3b2c71a36b5f23dce6b5fda0c67a6d0cedd1983 /src/node_serdes.cc | |
parent | 8bd6df8927c1363789b195020397c8a672a46a0a (diff) |
lib: enable TypedArray and DataView for the v8 module
This commit allow passing `TypedArray` and `DataView` to:
- v8.deserialize()
- new v8.Deserializer()
- v8.serializer.writeRawBytes()
PR-URL: https://github.com/nodejs/node/pull/23953
Refs: https://github.com/nodejs/node/issues/1826
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/node_serdes.cc')
-rw-r--r-- | src/node_serdes.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/node_serdes.cc b/src/node_serdes.cc index bb7890a7300..0a410944458 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -266,9 +266,9 @@ void SerializerContext::WriteRawBytes(const FunctionCallbackInfo<Value>& args) { SerializerContext* ctx; ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); - if (!args[0]->IsUint8Array()) { + if (!args[0]->IsArrayBufferView()) { return node::THROW_ERR_INVALID_ARG_TYPE( - ctx->env(), "source must be a Uint8Array"); + ctx->env(), "source must be a TypedArray or a DataView"); } ctx->serializer_.WriteRawBytes(Buffer::Data(args[0]), @@ -317,9 +317,9 @@ MaybeLocal<Object> DeserializerContext::ReadHostObject(Isolate* isolate) { void DeserializerContext::New(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - if (!args[0]->IsUint8Array()) { + if (!args[0]->IsArrayBufferView()) { return node::THROW_ERR_INVALID_ARG_TYPE( - env, "buffer must be a Uint8Array"); + env, "buffer must be a TypedArray or a DataView"); } new DeserializerContext(env, args.This(), args[0]); |