discontinuing todays session
This commit is contained in:
parent
9b45a78e58
commit
8e9e62b3d0
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,3 +9,5 @@ build_test
|
|||||||
.jshintignore
|
.jshintignore
|
||||||
.jshintrc
|
.jshintrc
|
||||||
.validate.json
|
.validate.json
|
||||||
|
y.js
|
||||||
|
y.js.map
|
||||||
|
@ -94,37 +94,6 @@ var Struct = {
|
|||||||
}
|
}
|
||||||
op.origin = op.left;
|
op.origin = op.left;
|
||||||
op.struct = "Insert";
|
op.struct = "Insert";
|
||||||
yield* Struct.Operation.create.call(this, op);
|
|
||||||
|
|
||||||
if (op.left != null) {
|
|
||||||
var left = yield* this.getOperation(op.left);
|
|
||||||
left.right = op.id;
|
|
||||||
yield* this.setOperation(left);
|
|
||||||
}
|
|
||||||
if (op.right != null) {
|
|
||||||
var right = yield* this.getOperation(op.right);
|
|
||||||
right.left = op.id;
|
|
||||||
yield* this.setOperation(right);
|
|
||||||
}
|
|
||||||
var parent = yield* this.getOperation(op.parent);
|
|
||||||
if (op.parentSub != null){
|
|
||||||
if (compareIds(parent.map[op.parentSub], op.right)) {
|
|
||||||
parent.map[op.parentSub] = op.id;
|
|
||||||
yield* this.setOperation(parent);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var start = compareIds(parent.start, op.right);
|
|
||||||
var end = compareIds(parent.end, op.left);
|
|
||||||
if (start || end) {
|
|
||||||
if (start) {
|
|
||||||
parent.start = op.id;
|
|
||||||
}
|
|
||||||
if (end) {
|
|
||||||
parent.end = op.id;
|
|
||||||
}
|
|
||||||
yield* this.setOperation(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return op;
|
return op;
|
||||||
},
|
},
|
||||||
encode: function(op){
|
encode: function(op){
|
||||||
@ -284,11 +253,11 @@ var Struct = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
List: {
|
List: {
|
||||||
create: function*( op : Op){
|
create: function( op : Op){
|
||||||
op.start = null;
|
op.start = null;
|
||||||
op.end = null;
|
op.end = null;
|
||||||
op.struct = "List";
|
op.struct = "List";
|
||||||
return yield* Struct.Operation.create.call(this, op);
|
return Struct.Operation.create(op);
|
||||||
},
|
},
|
||||||
encode: function(op){
|
encode: function(op){
|
||||||
return {
|
return {
|
||||||
|
@ -1,35 +1,50 @@
|
|||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
class Map {
|
class Map {
|
||||||
constructor (_model) {
|
constructor (os, _model) {
|
||||||
this._model = _model;
|
this._model = _model;
|
||||||
|
this.os = os;
|
||||||
}
|
}
|
||||||
*val () {
|
val () {
|
||||||
var t = yield "transaction";
|
if (arguments.length === 1) {
|
||||||
var model = yield* t.getOperation(this._model);
|
if (this.opContents[arguments[0]] == null) {
|
||||||
if (arguments.length === 0) {
|
return this.contents[arguments[0]];
|
||||||
var res = {};
|
} else {
|
||||||
for (var key in model.map) {
|
let def = Promise.defer();
|
||||||
var v = yield* Y.Struct.Map.get.call(t, model, key);
|
var oid = this.opContents[arguments[0]];
|
||||||
if (v != null) {
|
this.os.requestTransaction(function*(){
|
||||||
res[key] = v;
|
def.resolve(yield* this.getType(oid));
|
||||||
}
|
});
|
||||||
|
return def.promise;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
} else if (arguments.length === 1) {
|
|
||||||
return yield* Y.Struct.Map.get.call(t, model, arguments[0]);
|
|
||||||
} else if (arguments.length === 2) {
|
} else if (arguments.length === 2) {
|
||||||
return yield* Y.Struct.Map.set.call(t, model, arguments[0], arguments[1]);
|
var key = arguments[0];
|
||||||
|
var value = arguments[1];
|
||||||
|
let def = Promise.defer();
|
||||||
|
var _model = this._model;
|
||||||
|
this.os.requestTransaction(function*(){
|
||||||
|
var model = yield* this.getOperation(_model);
|
||||||
|
def.resolve(yield* Y.Struct.Map.set.call(this, model, key, value));
|
||||||
|
});
|
||||||
|
return def.promise;
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Implement this case!");
|
throw new Error("Implement this case!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
*delete (key) {
|
*delete (key) {
|
||||||
var t = yield "transaction";
|
var t = yield "transaction";
|
||||||
var model = yield* t.getOperation(this._model);
|
var model = yield* t.getOperation(this._model);
|
||||||
yield* Y.Struct.Map.delete.call(t, model, key);
|
yield* Y.Struct.Map.delete.call(t, model, key);
|
||||||
}
|
}*/
|
||||||
_changed () {
|
_changed (op) {
|
||||||
|
if (op.left === null) {
|
||||||
|
if (op.opContent != null) {
|
||||||
|
this.opContents[op.parentSub] = op.opContent;
|
||||||
|
} else {
|
||||||
|
this.contents[op.parentSub] = op.opContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user