@@ -1162,6 +1162,77 @@ export class Effected<out E extends Effect, out R> implements Iterable<E, R, unk
11621162 with ( handler : ( effected : any ) => unknown ) {
11631163 return handler ( this ) ;
11641164 }
1165+
1166+ /**
1167+ * Pipe the effected program through a series of functions.
1168+ * @returns
1169+ */
1170+ pipe < A , B = never > ( this : A , ab : ( a : A ) => B ) : B ;
1171+ pipe < A , B = never , C = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C ) : C ;
1172+ // prettier-ignore
1173+ pipe < A , B = never , C = never , D = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D ) : D ;
1174+ // prettier-ignore
1175+ pipe < A , B = never , C = never , D = never , E = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E ) : E ;
1176+ // prettier-ignore
1177+ pipe < A , B = never , C = never , D = never , E = never , F = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F ) : F ;
1178+ // prettier-ignore
1179+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G ) : G ;
1180+ // prettier-ignore
1181+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H ) : H ;
1182+ // prettier-ignore
1183+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I ) : I ;
1184+ // prettier-ignore
1185+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J ) : J ;
1186+ // prettier-ignore
1187+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K ) : K ;
1188+ // prettier-ignore
1189+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L ) : L ;
1190+ // prettier-ignore
1191+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M ) : M ;
1192+ // prettier-ignore
1193+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never , N = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M , mn : ( m : M ) => N ) : N ;
1194+ // prettier-ignore
1195+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never , N = never , O = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M , mn : ( m : M ) => N , no : ( n : N ) => O ) : O ;
1196+ // prettier-ignore
1197+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never , N = never , O = never , P = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M , mn : ( m : M ) => N , no : ( n : N ) => O , op : ( o : O ) => P ) : P ;
1198+ // prettier-ignore
1199+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never , N = never , O = never , P = never , Q = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M , mn : ( m : M ) => N , no : ( n : N ) => O , op : ( o : O ) => P , pq : ( p : P ) => Q ) : Q ;
1200+ // prettier-ignore
1201+ pipe < A , B = never , C = never , D = never , E = never , F = never , G = never , H = never , I = never , J = never , K = never , L = never , M = never , N = never , O = never , P = never , Q = never , R = never > ( this : A , ab : ( a : A ) => B , bc : ( b : B ) => C , cd : ( c : C ) => D , de : ( d : D ) => E , ef : ( e : E ) => F , fg : ( f : F ) => G , gh : ( g : G ) => H , hi : ( h : H ) => I , ij : ( i : I ) => J , jk : ( j : J ) => K , kl : ( k : K ) => L , lm : ( l : L ) => M , mn : ( m : M ) => N , no : ( n : N ) => O , op : ( o : O ) => P , pq : ( p : P ) => Q , qr : ( q : Q ) => R ) : R ;
1202+ pipe ( ...args : ( ( value : any ) => any ) [ ] ) : any {
1203+ // Optimization inspired by Effect
1204+ // https://github.com/Effect-TS/effect/blob/f293e97ab2a26f45586de106b85119c5d98ab4c7/packages/effect/src/Pipeable.ts#L491-L524
1205+ switch ( args . length ) {
1206+ case 0 :
1207+ return this ;
1208+ case 1 :
1209+ return args [ 0 ] ! ( this ) ;
1210+ case 2 :
1211+ return args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ;
1212+ case 3 :
1213+ return args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ;
1214+ case 4 :
1215+ return args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ;
1216+ case 5 :
1217+ return args [ 4 ] ! ( args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ) ;
1218+ case 6 :
1219+ return args [ 5 ] ! ( args [ 4 ] ! ( args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ) ) ;
1220+ case 7 :
1221+ return args [ 6 ] ! ( args [ 5 ] ! ( args [ 4 ] ! ( args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ) ) ) ;
1222+ case 8 :
1223+ return args [ 7 ] ! ( args [ 6 ] ! ( args [ 5 ] ! ( args [ 4 ] ! ( args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ) ) ) ) ;
1224+ case 9 :
1225+ return args [ 8 ] ! (
1226+ args [ 7 ] ! ( args [ 6 ] ! ( args [ 5 ] ! ( args [ 4 ] ! ( args [ 3 ] ! ( args [ 2 ] ! ( args [ 1 ] ! ( args [ 0 ] ! ( this ) ) ) ) ) ) ) ) ,
1227+ ) ;
1228+ default : {
1229+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1230+ let result = this ;
1231+ for ( let i = 0 , len = args . length ; i < len ; i ++ ) result = args [ i ] ! ( result ) ;
1232+ return result ;
1233+ }
1234+ }
1235+ }
11651236}
11661237
11671238interface EffectedDraft <
0 commit comments