From ee264dbaa2c81e29a091efd16601ec74a058f6d3 Mon Sep 17 00:00:00 2001 From: Mansehej Date: Wed, 13 May 2020 03:07:07 +0530 Subject: [PATCH] Y.Array insert operations return new length Y.Array functions - insert - push - unshift Return updated Y.Array length --- src/types/YArray.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/types/YArray.js b/src/types/YArray.js index 171eec8b..4c3a6835 100644 --- a/src/types/YArray.js +++ b/src/types/YArray.js @@ -101,6 +101,7 @@ export class YArray extends AbstractType { * * @param {number} index The index to insert content at. * @param {Array} content The array of content + * @return {number} The upated YArray length */ insert (index, content) { if (this.doc !== null) { @@ -110,24 +111,27 @@ export class YArray extends AbstractType { } else { /** @type {Array} */ (this._prelimContent).splice(index, 0, ...content) } + return this.length } /** * Appends content to this YArray. * * @param {Array} content Array of content to append. + * @return {number} The upated YArray length */ push (content) { - this.insert(this.length, content) + return this.insert(this.length, content) } /** * Preppends content to this YArray. * * @param {Array} content Array of content to preppend. + * @return {number} The upated YArray length */ unshift (content) { - this.insert(0, content) + return this.insert(0, content) } /**