@@ -189,10 +189,10 @@ void SerializerContext::WriteHeader(const FunctionCallbackInfo<Value>& args) {
189189void SerializerContext::WriteValue (const FunctionCallbackInfo<Value>& args) {
190190 SerializerContext* ctx;
191191 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
192- Maybe< bool > ret =
193- ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]);
194-
195- if (ret. IsJust ()) args. GetReturnValue (). Set (ret. FromJust ());
192+ bool ret;
193+ if ( ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]). To (&ret)) {
194+ args. GetReturnValue (). Set (ret);
195+ }
196196}
197197
198198void SerializerContext::SetTreatArrayBufferViewsAsHostObjects (
@@ -223,50 +223,55 @@ void SerializerContext::TransferArrayBuffer(
223223 SerializerContext* ctx;
224224 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
225225
226- Maybe<uint32_t > id = args[0 ]->Uint32Value (ctx->env ()->context ());
227- if (id.IsNothing ()) return ;
226+ uint32_t id;
227+ if (!args[0 ]->Uint32Value (ctx->env ()->context ()).To (&id)) {
228+ return ;
229+ }
228230
229- if (!args[1 ]->IsArrayBuffer ())
231+ if (!args[1 ]->IsArrayBuffer ()) {
230232 return node::THROW_ERR_INVALID_ARG_TYPE (
231233 ctx->env (), " arrayBuffer must be an ArrayBuffer" );
234+ }
232235
233236 Local<ArrayBuffer> ab = args[1 ].As <ArrayBuffer>();
234- ctx->serializer_ .TransferArrayBuffer (id.FromJust (), ab);
235- return ;
237+ ctx->serializer_ .TransferArrayBuffer (id, ab);
236238}
237239
238240void SerializerContext::WriteUint32 (const FunctionCallbackInfo<Value>& args) {
239241 SerializerContext* ctx;
240242 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
241243
242- Maybe< uint32_t > value = args[ 0 ]-> Uint32Value (ctx-> env ()-> context ()) ;
243- if (value. IsNothing ( )) return ;
244-
245- ctx-> serializer_ . WriteUint32 (value. FromJust ());
244+ uint32_t value;
245+ if (args[ 0 ]-> Uint32Value (ctx-> env ()-> context ()). To (&value )) {
246+ ctx-> serializer_ . WriteUint32 (value);
247+ }
246248}
247249
248250void SerializerContext::WriteUint64 (const FunctionCallbackInfo<Value>& args) {
249251 SerializerContext* ctx;
250252 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
251253
252- Maybe<uint32_t > arg0 = args[0 ]->Uint32Value (ctx->env ()->context ());
253- Maybe<uint32_t > arg1 = args[1 ]->Uint32Value (ctx->env ()->context ());
254- if (arg0.IsNothing () || arg1.IsNothing ())
254+ uint32_t hi;
255+ uint32_t lo;
256+
257+ if (!args[0 ]->Uint32Value (ctx->env ()->context ()).To (&hi) ||
258+ !args[1 ]->Uint32Value (ctx->env ()->context ()).To (&lo)) {
255259 return ;
260+ }
256261
257- uint64_t hi = arg0. FromJust () ;
258- uint64_t lo = arg1. FromJust () ;
259- ctx->serializer_ .WriteUint64 ((hi << 32 ) | lo );
262+ uint64_t hiu64 = hi ;
263+ uint64_t lou64 = lo ;
264+ ctx->serializer_ .WriteUint64 ((hiu64 << 32 ) | lou64 );
260265}
261266
262267void SerializerContext::WriteDouble (const FunctionCallbackInfo<Value>& args) {
263268 SerializerContext* ctx;
264269 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
265270
266- Maybe< double > value = args[ 0 ]-> NumberValue (ctx-> env ()-> context ()) ;
267- if (value. IsNothing ( )) return ;
268-
269- ctx-> serializer_ . WriteDouble (value. FromJust ());
271+ double value;
272+ if (args[ 0 ]-> NumberValue (ctx-> env ()-> context ()). To (&value )) {
273+ ctx-> serializer_ . WriteDouble (value);
274+ }
270275}
271276
272277void SerializerContext::WriteRawBytes (const FunctionCallbackInfo<Value>& args) {
@@ -341,9 +346,10 @@ void DeserializerContext::ReadHeader(const FunctionCallbackInfo<Value>& args) {
341346 DeserializerContext* ctx;
342347 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
343348
344- Maybe<bool > ret = ctx->deserializer_ .ReadHeader (ctx->env ()->context ());
345-
346- if (ret.IsJust ()) args.GetReturnValue ().Set (ret.FromJust ());
349+ bool ret;
350+ if (ctx->deserializer_ .ReadHeader (ctx->env ()->context ()).To (&ret)) {
351+ args.GetReturnValue ().Set (ret);
352+ }
347353}
348354
349355void DeserializerContext::ReadValue (const FunctionCallbackInfo<Value>& args) {
@@ -361,18 +367,20 @@ void DeserializerContext::TransferArrayBuffer(
361367 DeserializerContext* ctx;
362368 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
363369
364- Maybe<uint32_t > id = args[0 ]->Uint32Value (ctx->env ()->context ());
365- if (id.IsNothing ()) return ;
370+ uint32_t id;
371+ if (!args[0 ]->Uint32Value (ctx->env ()->context ()).To (&id)) {
372+ return ;
373+ }
366374
367375 if (args[1 ]->IsArrayBuffer ()) {
368376 Local<ArrayBuffer> ab = args[1 ].As <ArrayBuffer>();
369- ctx->deserializer_ .TransferArrayBuffer (id. FromJust () , ab);
377+ ctx->deserializer_ .TransferArrayBuffer (id, ab);
370378 return ;
371379 }
372380
373381 if (args[1 ]->IsSharedArrayBuffer ()) {
374382 Local<SharedArrayBuffer> sab = args[1 ].As <SharedArrayBuffer>();
375- ctx->deserializer_ .TransferSharedArrayBuffer (id. FromJust () , sab);
383+ ctx->deserializer_ .TransferSharedArrayBuffer (id, sab);
376384 return ;
377385 }
378386
@@ -433,9 +441,11 @@ void DeserializerContext::ReadRawBytes(
433441 DeserializerContext* ctx;
434442 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
435443
436- Maybe<int64_t > length_arg = args[0 ]->IntegerValue (ctx->env ()->context ());
437- if (length_arg.IsNothing ()) return ;
438- size_t length = length_arg.FromJust ();
444+ int64_t length_arg;
445+ if (!args[0 ]->IntegerValue (ctx->env ()->context ()).To (&length_arg)) {
446+ return ;
447+ }
448+ size_t length = length_arg;
439449
440450 const void * data;
441451 bool ok = ctx->deserializer_ .ReadRawBytes (length, &data);
0 commit comments