@@ -534,25 +534,80 @@ export interface IMaybe<T> extends IMonad<T> {
534534 flatMapMany < R > ( fn : ( val : NonNullable < T > ) => Promise < R > [ ] ) : Promise < IMaybe < NonNullable < R > [ ] > >
535535
536536 /**
537- * Combines this Maybe with another Maybe using a combiner function.
538- *
539- * If both Maybes are Some, applies the function to their values and returns
540- * a new Some containing the result. If either is None, returns None.
541- *
537+ * Combines this Maybe with one or more other Maybes using a combiner function.
538+ *
539+ * If all Maybes are Some, applies the function to their values and returns
540+ * a new Some containing the result. If any is None, returns None.
541+ *
542542 * @typeParam U - The type of the value in the other Maybe
543543 * @typeParam R - The type of the combined result
544544 * @param other - Another Maybe to combine with this one
545545 * @param fn - A function that combines the values from both Maybes
546- * @returns A new Maybe containing the combined result if both inputs are Some, otherwise None
547- *
546+ * @returns A new Maybe containing the combined result if all inputs are Some, otherwise None
547+ *
548548 * @example
549- * // Combine user name and email into a display string
549+ * // Combine two values
550550 * const name = maybe(user.name);
551551 * const email = maybe(user.email);
552- *
552+ *
553553 * const display = name.zipWith(email, (name, email) => `${name} <${email}>`);
554- * // Some("John Doe <[email protected] >") if both name and email exist 554+ * // Some("John Doe <[email protected] >") if both exist 555555 * // None if either is missing
556+ *
557+ * @example
558+ * // Combine three values
559+ * const firstName = maybe(user.firstName);
560+ * const lastName = maybe(user.lastName);
561+ * const email = maybe(user.email);
562+ *
563+ * const contact = firstName.zipWith(lastName, email, (first, last, email) => ({
564+ * fullName: `${first} ${last}`,
565+ * email
566+ * }));
567+ * // Some({ fullName: "John Doe", email: "john@example.com" }) if all exist
568+ * // None if any is missing
569+ *
570+ * @example
571+ * // Combine many values
572+ * const result = a.zipWith(b, c, d, e, (a, b, c, d, e) => a + b + c + d + e);
556573 */
557- zipWith < U extends NonNullable < unknown > , R > ( other : IMaybe < U > , fn : ( a : NonNullable < T > , b : U ) => NonNullable < R > ) : IMaybe < R >
574+ zipWith < U extends NonNullable < unknown > , R > (
575+ other : IMaybe < U > ,
576+ fn : ( a : NonNullable < T > , b : U ) => NonNullable < R >
577+ ) : IMaybe < R >
578+
579+ zipWith < U extends NonNullable < unknown > , V extends NonNullable < unknown > , R > (
580+ m1 : IMaybe < U > ,
581+ m2 : IMaybe < V > ,
582+ fn : ( a : NonNullable < T > , b : U , c : V ) => NonNullable < R >
583+ ) : IMaybe < R >
584+
585+ zipWith < U extends NonNullable < unknown > , V extends NonNullable < unknown > , W extends NonNullable < unknown > , R > (
586+ m1 : IMaybe < U > ,
587+ m2 : IMaybe < V > ,
588+ m3 : IMaybe < W > ,
589+ fn : ( a : NonNullable < T > , b : U , c : V , d : W ) => NonNullable < R >
590+ ) : IMaybe < R >
591+
592+ zipWith < U extends NonNullable < unknown > , V extends NonNullable < unknown > , W extends NonNullable < unknown > , X extends NonNullable < unknown > , R > (
593+ m1 : IMaybe < U > ,
594+ m2 : IMaybe < V > ,
595+ m3 : IMaybe < W > ,
596+ m4 : IMaybe < X > ,
597+ fn : ( a : NonNullable < T > , b : U , c : V , d : W , e : X ) => NonNullable < R >
598+ ) : IMaybe < R >
599+
600+ zipWith < U extends NonNullable < unknown > , V extends NonNullable < unknown > , W extends NonNullable < unknown > , X extends NonNullable < unknown > , Z extends NonNullable < unknown > , R > (
601+ m1 : IMaybe < U > ,
602+ m2 : IMaybe < V > ,
603+ m3 : IMaybe < W > ,
604+ m4 : IMaybe < X > ,
605+ m5 : IMaybe < Z > ,
606+ fn : ( a : NonNullable < T > , b : U , c : V , d : W , e : X , f : Z ) => NonNullable < R >
607+ ) : IMaybe < R >
608+
609+ // Variadic overload for 5+ Maybes
610+ zipWith < R > (
611+ ...args : [ ...IMaybe < NonNullable < unknown > > [ ] , ( ...values : NonNullable < unknown > [ ] ) => NonNullable < R > ]
612+ ) : IMaybe < R >
558613}
0 commit comments