conditional-chain
conditional-chain copied to clipboard
what is "chain" for?
here i tried to tyepscript the whole:
const cond = <T = any>(chain: T) => ({
if(condition: boolean, thanF: (obj?: T) => T, elseF?: (obj?: T) => T) {
return cond(condition ? thanF(chain) : elseF ? elseF(chain) : chain);
},
chain(f: any) {
return cond(f(chain));
},
end() {
return chain;
}
})
what is the "chain" function for ?