Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DifferenceWith #71

Open
assertnotnull opened this issue Feb 14, 2023 · 6 comments · May be fixed by #106
Open

Add DifferenceWith #71

assertnotnull opened this issue Feb 14, 2023 · 6 comments · May be fixed by #106
Labels

Comments

@assertnotnull
Copy link

Useful for array of objects

@JUSTIVE
Copy link

JUSTIVE commented Feb 11, 2024

Could you describe it more specifically? for example, a signature for the function, and desired behavior.

@assertnotnull
Copy link
Author

It would accept a function like such https://ramdajs.com/docs/#differenceWith because difference works only with primitives.

@JUSTIVE
Copy link

JUSTIVE commented Feb 13, 2024

I got this. but how about changing the name to differenceBy? all the other functions in ts-belt which take another comparing function use ~By in their names. I forgot zipWith. I committed a PR, please check it out to see if it meets your requirements.

@JUSTIVE JUSTIVE linked a pull request Feb 13, 2024 that will close this issue
@JUSTIVE
Copy link

JUSTIVE commented Feb 13, 2024

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.

@assertnotnull
Copy link
Author

I don't think I have anything against the proposal

@JUSTIVE
Copy link

JUSTIVE commented Feb 14, 2024

Great! PR updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants