A simple javascript implementation of LWW-Element-Set
You can import this as if this was a library.
On package.json
"dependencies": {
"lww-set": "heinrich10/lww-set",
"express": "^4.16.4",
"amk-wrap": "^0.1.0"
. . .
}
On a js file
const LwwSet = require('lww-set');
const lwwSet = new LwwSet();
lwwSet.add('element1', Date.now());
add(element, timestamp)
- add an element to the set
remove(element, timestamp)
- remove an element to the set
exist(element)
- returns true if element exist in set
get()
- get all elements from the set
to run test case:
- run
npm install
- run
npm test
Assumptions:
- this is a simple implementation, therefore, there is no validation, so if you input the wrong data type, something could go wrong