realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Align `Set` with JavaScript `Set`

Open takameyer opened this issue 2 years ago • 4 comments

Currently, the Set does not perfectly reflect a JS Set. Set currently extends an OrderedCollection, which implements a ReadOnlyArray.

  • keys should return values (Sets aren't syntactically index accessible)
  • Set is not ordered, so extending OrderedCollection may lead to assumptions that the Set is ordered.
  • May be worth looking into Set implementing a JS Set, rather than extending OrderedCollection

takameyer avatar Jul 12 '23 12:07 takameyer

Our RealmSet extends the OrderedCollection which implements these for it?

kraenhansen avatar Jul 14 '23 13:07 kraenhansen

@kraenhansen Good point. I'll have to write some tests as none of this is covered. The implementation of keys does not match a JS Set, which is the same result as values.

takameyer avatar Jul 18 '23 09:07 takameyer

I have created test cases for this feature.

takameyer avatar Jul 18 '23 09:07 takameyer

@kraenhansen I've refactored the feature request. This would be a breaking change, but probably not high value.

takameyer avatar Jul 18 '23 13:07 takameyer