import type { Fn } from "@thi.ng/api" ; remarks example example param order export const swizzle = < T > ( order ) : Fn < T , any [ ] > => { const [ a , b , c , d , e , f , g , h ] = order ; switch ( order . length ) { case 0 : return ( ) => [ ] ; case 1 : return ( x ) => [ x [ a ] ] ; case 2 : return ( x ) => [ x [ a ] , x [ b ] ] ; case 3 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] ] ; case 4 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] , x [ d ] ] ; case 5 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] , x [ d ] , x [ e ] ] ; case 6 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] , x [ d ] , x [ e ] , x [ f ] ] ; case 7 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] , x [ d ] , x [ e ] , x [ f ] , x [ g ] ] ; case 8 : return ( x ) => [ x [ a ] , x [ b ] , x [ c ] , x [ d ] , x [ e ] , x [ f ] , x [ g ] , x [ h ] ] ; default : return ( x ) => { const res = [ ] ; for ( let i = order . length ; i -- > 0 ; ) { res [ i ] = x [ order [ i ] ] ; } return res ; } ; } } ;