Open assertnotnull opened 1 year ago
Could you describe it more specifically? for example, a signature for the function, and desired behavior.
It would accept a function like such https://ramdajs.com/docs/#differenceWith because difference works only with primitives.
I got this. but how about changing the name to I forgot differenceBy
? all the other functions in ts-belt which take another comparing function use ~By
in their names.zipWith
. I committed a PR, please check it out to see if it meets your requirements.
maybe a 'a=>'b
function for the compare function rather than ('a 'a) => bool
would be better i guess? If it's a symmetric comparison, why not just evaluate a new value from its element?
//current implementation(which is same as ramda's signature)
A.differenceWith<{a:number}>([{a:1},{a:2}], [{a:1},{a:3}], ({a:x}, {a:y})=> x === y)
A.differenceWith([{a:1},{a:2}], [{a:1},{a:3}], F.equals) // which should work just same as A.difference
//proposed implementation
A.differenceWith<{a:number},number>([{a:1},{a:2}], [{a:1},{a:3}], D.getExn('a'))
A.differenceWith([{a:1},{a:2}], [{a:1},{a:3}], F.identity) // which should work just same as A.difference
this makes the third argument into a unary function, which works fluently with many other functions in ts-belt. the PR is written in ramda's signature, but let me know how do you think.
I don't think I have anything against the proposal
Great! PR updated!
Useful for array of objects