From 4c46ebfb453b99b7406ed5e56360c4f12dee26c5 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Sun, 1 Nov 2020 10:01:04 -0800 Subject: [PATCH] add Y.Array.from --- src/types/YArray.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/types/YArray.js b/src/types/YArray.js index b0f78fdb..d1f2e7ed 100644 --- a/src/types/YArray.js +++ b/src/types/YArray.js @@ -53,6 +53,18 @@ export class YArray extends AbstractType { this._searchMarker = [] } + /** + * Construct a new YArray containing the specified items. + * @template T + * @param {Array} items + * @return {YArray} + */ + static from(items) { + const a = new YArray() + a.push(items) + return a + } + /** * Integrate this type into the Yjs instance. *