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
|
||||
.jshintrc
|
||||
.validate.json
|
||||
y.js
|
||||
y.js.map
|
||||
|
@ -94,37 +94,6 @@ var Struct = {
|
||||
}
|
||||
op.origin = op.left;
|
||||
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;
|
||||
},
|
||||
encode: function(op){
|
||||
@ -284,11 +253,11 @@ var Struct = {
|
||||
}
|
||||
},
|
||||
List: {
|
||||
create: function*( op : Op){
|
||||
create: function( op : Op){
|
||||
op.start = null;
|
||||
op.end = null;
|
||||
op.struct = "List";
|
||||
return yield* Struct.Operation.create.call(this, op);
|
||||
return Struct.Operation.create(op);
|
||||
},
|
||||
encode: function(op){
|
||||
return {
|
||||
|
@ -1,35 +1,50 @@
|
||||
|
||||
(function(){
|
||||
class Map {
|
||||
constructor (_model) {
|
||||
constructor (os, _model) {
|
||||
this._model = _model;
|
||||
this.os = os;
|
||||
}
|
||||
*val () {
|
||||
var t = yield "transaction";
|
||||
var model = yield* t.getOperation(this._model);
|
||||
if (arguments.length === 0) {
|
||||
var res = {};
|
||||
for (var key in model.map) {
|
||||
var v = yield* Y.Struct.Map.get.call(t, model, key);
|
||||
if (v != null) {
|
||||
res[key] = v;
|
||||
}
|
||||
val () {
|
||||
if (arguments.length === 1) {
|
||||
if (this.opContents[arguments[0]] == null) {
|
||||
return this.contents[arguments[0]];
|
||||
} else {
|
||||
let def = Promise.defer();
|
||||
var oid = this.opContents[arguments[0]];
|
||||
this.os.requestTransaction(function*(){
|
||||
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) {
|
||||
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 {
|
||||
throw new Error("Implement this case!");
|
||||
}
|
||||
}
|
||||
/*
|
||||
*delete (key) {
|
||||
var t = yield "transaction";
|
||||
var model = yield* t.getOperation(this._model);
|
||||
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