A Nostr datastore (eg a relay) is actually just a Set. So here's an EventSet class, which implements the ES6 Set interface, and supports replaceable events: https://gitlab.com/soapbox-pub/ditto/-/blob/main/src/utils/event-set.ts