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

Enhancements to the proposal Set methods #45

Closed
unadlib opened this issue Jun 29, 2024 · 3 comments
Closed

Enhancements to the proposal Set methods #45

unadlib opened this issue Jun 29, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@unadlib
Copy link
Owner

unadlib commented Jun 29, 2024

This is a proposal https://github.com/tc39/proposal-set-methods to add methods like union and intersection to JavaScript's built-in Set class.

It is currently at stage 4: it has been tc39/ecma262#3306. This repository is no longer active.

This would add the following methods:

  • Set.prototype.intersection(other)
  • Set.prototype.union(other)
  • Set.prototype.difference(other)
  • Set.prototype.symmetricDifference(other)
  • Set.prototype.isSubsetOf(other)
  • Set.prototype.isSupersetOf(other)
  • Set.prototype.isDisjointFrom(other)

With the support of the latest major browsers, it is necessary for Mutative to support it as well.

Check compatibility

@unadlib unadlib added the enhancement New feature or request label Jun 29, 2024
@unadlib
Copy link
Owner Author

unadlib commented Nov 15, 2024

Compatibility

Version
Chrome 122
Edge 122
Firefox 127
Opera 108
Safari 17
Chrome Android 122
Firefox for Android 127
Opera Android 81
Safari on iOS 17
Samsung Internet 26.0
WebView Android 122
WebView on iOS 17
Deno 1.42
Node.js 22.0.0

@unadlib
Copy link
Owner Author

unadlib commented Nov 17, 2024

Here's a performance comparison of two different Set shallow copy methods. We have reason to use Set.prototype.difference to ensure optimal Set shallow copy performance.

This will allow Mutative's Set shallow copy performance to improve by 3X to 6X.

new Set(baseState.values());;

// vs 

baseState.difference(new Set());
image

@unadlib
Copy link
Owner Author

unadlib commented Nov 17, 2024

Based on the new Set shallow copy approach, Mutative's Set operation performance has improved from 3X to 4X faster compared to Immer.

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

No branches or pull requests

1 participant