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

JSON CRDT refactor and automated docs #363

Merged
merged 16 commits into from
Oct 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(json-crdt): 💡 rename .tup() to .vec()
streamich committed Oct 29, 2023
commit 6daa5bd579913f79bd03031e515ebf56a09da73f
3 changes: 1 addition & 2 deletions src/json-crdt/model/api/ModelApi.ts
Original file line number Diff line number Diff line change
@@ -133,9 +133,8 @@ export class ModelApi<Value extends JsonNode = JsonNode> {
*
* @param path Path at which to locate a node.
* @returns A local changes API for a `vec` node.
* @todo Rename to `vec`.
*/
public tup(path?: ApiPath) {
public vec(path?: ApiPath) {
return this.node.tup(path);
}

12 changes: 6 additions & 6 deletions src/json-crdt/model/api/__tests__/TupleApi.spec.ts
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ test('can edit a tuple', () => {
const doc = Model.withLogicalClock();
const api = doc.api;
api.root(api.builder.vec());
api.tup([]).set([[1, 'a']]);
expect(api.tup([]).view()).toEqual([undefined, 'a']);
api.vec([]).set([[1, 'a']]);
expect(api.vec([]).view()).toEqual([undefined, 'a']);
});

onlyOnNode20('events', () => {
@@ -17,7 +17,7 @@ onlyOnNode20('events', () => {
api.root(vec(1, 2));
let cnt = 0;
const onView = () => cnt++;
const tuple = api.tup([]);
const tuple = api.vec([]);
tuple.events.on('view', onView);
expect(cnt).toBe(0);
tuple.set([[0, 1.5]]);
@@ -37,7 +37,7 @@ onlyOnNode20('events', () => {
api.root(vec(1, 2));
let cnt = 0;
const onView = () => cnt++;
const tuple = api.tup([]);
const tuple = api.vec([]);
tuple.events.on('view', onView);
expect(cnt).toBe(0);
tuple.set([[0, 1.5]]);
@@ -60,7 +60,7 @@ onlyOnNode20('events', () => {
api.root(vec(1, 2));
let cnt = 0;
const onView = () => cnt++;
const tuple = api.tup([]);
const tuple = api.vec([]);
tuple.events.on('view', onView);
expect(cnt).toBe(0);
tuple.set([[0, 1.5]]);
@@ -81,7 +81,7 @@ onlyOnNode20('events', () => {
api.root(vec(1, 2));
let cnt = 0;
const onView = () => cnt++;
const tuple = api.tup([]);
const tuple = api.vec([]);
tuple.events.on('view', onView);
expect(cnt).toBe(0);
tuple.set([[0, 1.5]]);