-
Notifications
You must be signed in to change notification settings - Fork 52
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 support for array.every #52
Conversation
Thanks! Could you add a unit test that tests the method?
This is a tricky one. In a distributed collaboration scenario, I'm not yet convinced "set" using splice is really safe. Because slice is a delete + insert operation, I think the following would happen if both Alice and Bob assign a new element to arr[2] at the same time:
When both changes sync, we'd end up with:
With "insert" and "delete", and even "splice" names for operations this result makes sense. But when doing an assignment ( For this reason, until now I decided not to implement this method (I think it would cause quite some confusion and broken applications because devs won't understand the impact). What do you think? |
EveryAdded simple tests for every. Let me know if you want to me to add anything else (while I am at it, I might add tests for find and some other methods with missing tests in future PR's) SetAs for set, that makes sense. I can see the issue yjs/yjs#16 where this is being discussed in yjs. Thinking through it, the options one has are:
Am I missing anything? Potential ImprovementsI agree with the unexpected nature of set. I have two optional suggestions that might help here:
Something along the line of What do you think? |
I think this would make most sense. In the code, maybe add a comment that links to yjs/yjs#16 and this issue to explain the decision. |
Pull Request Test Coverage Report for Build 1811245091
💛 - Coveralls |
@YousefED Sure, if I will get to it I will do it in a separate PR. |
Pull Request Test Coverage Report for Build 1811245091Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There are a few basic array methods missing in the current array proxy implementation,
every
is one of them so this is a small PR to add it.I would like to add
set
by index next. I see you are throwing an error there. What do you think about implementing it using splice?