diff --git a/include/v8.h b/include/v8.h index 6081abc95c..c56c31b31f 100644 --- a/include/v8.h +++ b/include/v8.h @@ -3217,6 +3217,10 @@ class V8_EXPORT Object : public Value { public: V8_DEPRECATE_SOON("Use maybe version", bool Set(Local key, Local value)); + /** + * Set only return Just(true) or Empty(), so if it should never fail, use + * result.Check(). + */ V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); @@ -8716,6 +8720,14 @@ class Maybe { */ V8_INLINE T ToChecked() const { return FromJust(); } + /** + * Short-hand for ToChecked(), which doesn't return a value. To be used, where + * the actual value of the Maybe is not needed like Object::Set. + */ + V8_INLINE void Check() const { + if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing(); + } + /** * Converts this Maybe<> to a value of type T. If this Maybe<> is * nothing (empty), |false| is returned and |out| is left untouched.