deno.land / x / rambda@v9.1.1 / source / flip.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function flipFn(fn){ return (...input) => { if (input.length === 1){ return holder => fn(holder, input[ 0 ]) } else if (input.length === 2){ return fn(input[ 1 ], input[ 0 ]) } else if (input.length === 3){ return fn( input[ 1 ], input[ 0 ], input[ 2 ] ) } else if (input.length === 4){ return fn( input[ 1 ], input[ 0 ], input[ 2 ], input[ 3 ] ) }
throw new Error('R.flip doesn\'t work with arity > 4') }}
export function flip(fn){ return flipFn(fn)}
rambda

Version Info

Tagged at
2 months ago