Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions src/lseq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# lseq

The LSEQ CRDT provides a clever allocation strategy for a distributed sequence of basic elements
that can be lines, words or characters.

## References

* [Logoot-Undo: Distributed Collaborative Editing System on P2P Networks](https://hal.archives-ouvertes.fr/hal-00450416/)
* [LSEQ: an Adaptive Structure for Sequences in Distributed Collaborative Editing](https://hal.archives-ouvertes.fr/hal-00921633/)
15 changes: 15 additions & 0 deletions src/lseq/createLseqAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const createLseqInsertAction = name => (id, value) => ({
type: `LSEQ_INSERT_${name}`,
payload: {
id,
value,
},
});

export const createLseqRemoveAction = name => (id, value) => ({
type: `LSEQ_REMOVE_${name}`,
payload: {
id,
value,
},
});
41 changes: 41 additions & 0 deletions src/lseq/createLseqAction.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { createLseqInsertAction, createLseqRemoveAction } from './createLseqAction';

describe('createLseqAction', () => {
describe('createLseqInsertAction', () => {
it('should be a function', () => {
expect(typeof createLseqInsertAction).toBe('function');
});

it('should return an action object', () => {
const expected = {
type: 'LSEQ_INSERT_AA',
payload: {
id: 'A',
value: 1,
},
};
const countA = createLseqInsertAction('AA');
const result = countA('A', 1);
expect(result).toEqual(expected);
});
});

describe('createLseqRemoveAction', () => {
it('should be a function', () => {
expect(typeof createLseqRemoveAction).toBe('function');
});

it('should return an action object', () => {
const expected = {
type: 'LSEQ_REMOVE_AA',
payload: {
id: 'A',
value: 1,
},
};
const countA = createLseqRemoveAction('AA');
const result = countA('A', 1);
expect(result).toEqual(expected);
});
});
});
31 changes: 31 additions & 0 deletions src/lseq/createLseqReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const lseqInitalState = {
type: 'pn-counter',
p: {},
n: {},
};

export const createLseqReducer = name => (state = lseqInitalState, action) => {
if (!state || !action) {
return lseqInitalState;
}
switch (action.type) {
case `LSEQ_INSERT_${name}`:
if (action.payload) {
return state;
}
break;
case `LSEQ_REMOVE_${name}`:
if (action.payload) {
return state;
}
break;
case `LSEQ_MERGE_${name}`:
if (action.payload) {
return state;
}
break;
default:
return state;
}
return state;
};
7 changes: 7 additions & 0 deletions src/lseq/createLseqReducer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createLseqReducer } from './createLseqReducer';

describe('createLseqReducer', () => {
it('should be a function', () => {
expect(typeof createLseqReducer).toBe('function');
});
});
1 change: 0 additions & 1 deletion src/lseq/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/lseq/lseqSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default state => state;
7 changes: 7 additions & 0 deletions src/lseq/lseqSelector.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import lseqSelector from './lseqSelector';

describe('lseqSelector', () => {
it('should be a function', () => {
expect(typeof lseqSelector).toBe('function');
});
});
3 changes: 0 additions & 3 deletions test/createEventualAction.spec.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/createEventualReducer.spec.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/redux-eventually.spec.js

This file was deleted.