Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
synchro of spec with lseqarray, package and license
Browse files Browse the repository at this point in the history
  • Loading branch information
Chat-Wane committed Oct 13, 2014
1 parent 71ac95e commit efe1a6e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2014 Chat-Wane

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 2 additions & 2 deletions lib/lseqtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ LSEQTree.prototype.applyInsert = function(e, i){
if (result != -1){
// #3a if it exists, return the index of insertion
this.length += 1;
return (this.root.getIndex(node)-1);
return this.root.getIndex(node);
} else {
// #3b return -1 otherwise
return -1;
Expand All @@ -143,7 +143,7 @@ LSEQTree.prototype.applyRemove = function(i){
return -1;
} else {
this.length -= 1;
return (position-1);
return position;
};
};

Expand Down
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lseqtree",
"version": "0.1.0",
"author": "Chat-Wane <[email protected]>",
"description": "A data structure for distributed arrays using the LSEQ allocation strategy.",
"main": "./lib/lseqtree.js",
"repository": {
"type": "git",
"url": "https://github.com/chat-wane/LSEQTree.git"
},
"keywords": [
"distributed structure",
"CRDT",
"LSEQ",
"tree",
"array",
"vector"
],
"dependencies": {
"BigInt": "5.4.x"
},
"devDependencies": {
"expect.js": "0.2.x",
"mocha": "1.17.x"
},
"bundledDependencies": [
"BigInt"
],
"license": "MIT",
"engines": {
"node": ">=0.10.28"
}
}
4 changes: 2 additions & 2 deletions test/testlseqtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ describe('lseqtree.js', function(){
var exist = lseq.applyInsert(ei._e,ei._i);
expect(exist).to.be.eql(-1);
var position = lseq2.applyInsert(ei._e,ei._i);
expect(position).to.be.eql(0);
expect(position).to.be.eql(1);
});
});
describe('applyRemove', function(){
it('try to delete a non existing element', function(){
var lseq = new LSEQ(42);
var ei = lseq.insert('a',0);
var position = lseq.applyRemove(ei._i);
expect(position).to.be.eql(0);
expect(position).to.be.eql(1);
var exist = lseq.applyRemove(ei._i);
expect(exist).to.be.eql(-1);
});
Expand Down

0 comments on commit efe1a6e

Please sign in to comment.