File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -922,15 +922,19 @@ export class OptClass<T> extends ConstructType<[T] | []> {
922922 case 0 :
923923 return [ ] ;
924924 case 1 : {
925+ // Save the current state of the Pipe `b` to allow rollback in case of an error
925926 const checkpoint = b . save ( ) ;
926927 try {
927- const v = this . _type . decodeValue ( b , opt . _type )
928+ // Attempt to decode a value using the `_type` of the current instance
929+ const v = this . _type . decodeValue ( b , opt . _type ) ;
930+ // If decoding succeeds, return the value wrapped in an array
928931 return [ v ] ;
929- } catch ( e : any ) {
932+ } catch ( e : any ) {
933+ // If an error occurs during decoding, restore the Pipe `b` to its previous state
930934 b . restore ( checkpoint ) ;
931- // skip value at wire type ( to advance b)
932- const v = opt . _type . decodeValue ( b , opt . _type )
933- // retun none
935+ // Skip the value at the current wire type to advance the Pipe `b` position
936+ opt . _type . decodeValue ( b , opt . _type ) ;
937+ // Return an empty array to indicate a ` none` value
934938 return [ ] ;
935939 }
936940 }
You can’t perform that action at this time.
0 commit comments