@@ -187,10 +187,10 @@ void SerializerContext::WriteHeader(const FunctionCallbackInfo<Value>& args) {
187187void SerializerContext::WriteValue (const FunctionCallbackInfo<Value>& args) {
188188 SerializerContext* ctx;
189189 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
190- Maybe< bool > ret =
191- ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]);
192-
193- if (ret. IsJust ()) args. GetReturnValue (). Set (ret. FromJust ());
190+ bool ret;
191+ if ( ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]). To (&ret)) {
192+ args. GetReturnValue (). Set (ret);
193+ }
194194}
195195
196196void 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) {
@@ -360,18 +366,20 @@ void DeserializerContext::TransferArrayBuffer(
360366 DeserializerContext* ctx;
361367 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
362368
363- Maybe<uint32_t > id = args[0 ]->Uint32Value (ctx->env ()->context ());
364- if (id.IsNothing ()) return ;
369+ uint32_t id;
370+ if (!args[0 ]->Uint32Value (ctx->env ()->context ()).To (&id)) {
371+ return ;
372+ }
365373
366374 if (args[1 ]->IsArrayBuffer ()) {
367375 Local<ArrayBuffer> ab = args[1 ].As <ArrayBuffer>();
368- ctx->deserializer_ .TransferArrayBuffer (id. FromJust () , ab);
376+ ctx->deserializer_ .TransferArrayBuffer (id, ab);
369377 return ;
370378 }
371379
372380 if (args[1 ]->IsSharedArrayBuffer ()) {
373381 Local<SharedArrayBuffer> sab = args[1 ].As <SharedArrayBuffer>();
374- ctx->deserializer_ .TransferSharedArrayBuffer (id. FromJust () , sab);
382+ ctx->deserializer_ .TransferSharedArrayBuffer (id, sab);
375383 return ;
376384 }
377385
@@ -432,9 +440,11 @@ void DeserializerContext::ReadRawBytes(
432440 DeserializerContext* ctx;
433441 ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
434442
435- Maybe<int64_t > length_arg = args[0 ]->IntegerValue (ctx->env ()->context ());
436- if (length_arg.IsNothing ()) return ;
437- size_t length = length_arg.FromJust ();
443+ int64_t length_arg;
444+ if (!args[0 ]->IntegerValue (ctx->env ()->context ()).To (&length_arg)) {
445+ return ;
446+ }
447+ size_t length = length_arg;
438448
439449 const void * data;
440450 bool ok = ctx->deserializer_ .ReadRawBytes (length, &data);
0 commit comments