diff --git a/README.md b/README.md index 107ca6952cd9195055e1f69b6971e75489dc75b2..f2c18332801f773cf53990ea2617b7b68c069271 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,14 @@ If you want to see an issue fixed, please subscribe to the thread (or remind me ## Changelog +### 11.0.0 + +* **All types now return a single event instead of list of events** + * Insert events contain a list of values +* Improved performance for large insertions & deletions +* Several bugfixes (offline editing related) +* Native support for node 4 (see #49) + ### 10.0.0 * Support for more complex types (a type can be a composition of several types) diff --git a/src/SpecHelper.js b/src/SpecHelper.js index 0fe85a8f31c8bdd35c27b4380df377df8136ffeb..7a0f2b07ff761bb67954d4711574eacc9c0a1ce4 100644 --- a/src/SpecHelper.js +++ b/src/SpecHelper.js @@ -74,8 +74,14 @@ function getRandomNumber (n) { g.getRandomNumber = getRandomNumber function getRandomString () { - var tokens = 'abcdefäö' // ü\n\n\n\n\n\n\n' - return tokens[getRandomNumber(tokens.length)] + var chars = 'abcdefäö' + var char = chars[getRandomNumber(chars.length)] // ü\n\n\n\n\n\n\n' + var length = getRandomNumber(7) + var string = '' + for (var i = 0; i < length; i++) { + string += char + } + return string } g.getRandomString = getRandomString diff --git a/src/Struct.js b/src/Struct.js index 6cfe50778a8ca44f7dbe1cc4640a464918c997fc..592e23216491f30b19c187aff690a3bcff8a2230 100644 --- a/src/Struct.js +++ b/src/Struct.js @@ -245,11 +245,12 @@ module.exports = function (Y/* :any */) { } // is a child of a map struct. // Then also make sure that only the most left element is not deleted + // We do not call the type in this case (this is what the third parameter is for) if (op.right != null) { - yield* this.deleteOperation(op.right, 1) + yield* this.deleteOperation(op.right, 1, true) } if (op.left != null) { - yield* this.deleteOperation(op.id, 1) + yield* this.deleteOperation(op.id, 1, true) } } else { if (right == null || left == null) { diff --git a/src/Transaction.js b/src/Transaction.js index 57b70e3b25b70343d6e3df04dfc88383629208ee..7f0275bf09e811815a00780a00f9018a9618c66c 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -174,7 +174,7 @@ module.exports = function (Y/* :any */) { /* Mark an operation as deleted, and add it to the GC, if possible. */ - * deleteOperation (targetId, length) /* :Generator<any, any, any> */ { + * deleteOperation (targetId, length, preventCallType) /* :Generator<any, any, any> */ { if (length == null) { length = 1 } @@ -253,7 +253,7 @@ module.exports = function (Y/* :any */) { } else { right = null } - if (callType) { + if (callType && !preventCallType) { var type = this.store.initializedTypes[JSON.stringify(target.parent)] if (type != null) { yield* type._changed(this, { diff --git a/src/Utils.js b/src/Utils.js index d50b51ee56a81dd658407b4d4c19f818138b911c..08beef873024be0bf25ce42a87880cfe7e6f984f 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -91,9 +91,9 @@ module.exports = function (Y /* : any*/) { */ receivedOp (op) { if (this.awaiting <= 0) { - this.onevent([op]) + this.onevent(op) } else { - this.waiting.push(Y.utils.copyObject(op)) + this.waiting.push(op) } } /* @@ -102,8 +102,8 @@ module.exports = function (Y /* : any*/) { prematurely called operations are executed */ awaitAndPrematurelyCall (ops) { - this.awaiting++ - this.onevent(ops) + this.awaiting += ops.length + ops.forEach(this.onevent) } /* Call this when you successfully awaited the execution of n Insert operations @@ -132,7 +132,7 @@ module.exports = function (Y /* : any*/) { throw new Error('Expected Insert Operation!') } } - this._tryCallEvents() + this._tryCallEvents(n) } /* Call this when you successfully awaited the execution of n Delete operations @@ -155,17 +155,17 @@ module.exports = function (Y /* : any*/) { throw new Error('Expected Delete Operation!') } } - this._tryCallEvents() + this._tryCallEvents(n) } /* (private) Try to execute the events for the waiting operations */ - _tryCallEvents () { - this.awaiting-- - if (this.awaiting <= 0 && this.waiting.length > 0) { - var events = this.waiting + _tryCallEvents (n) { + this.awaiting -= n + if (this.awaiting === 0 && this.waiting.length > 0) { + var ops = this.waiting this.waiting = [] - this.onevent(events) + ops.forEach(this.onevent) } } }