/** * Event that describes the changes on a YArray * @template T */ export class YArrayEvent extends YEvent { /** * @param {YArray} yarray The changed type * @param {Transaction} transaction The transaction object */ constructor(yarray: YArray, transaction: Transaction); _transaction: Transaction; } /** * A shared Array implementation. * @template T * @extends AbstractType> * @implements {Iterable} */ export class YArray extends AbstractType> implements Iterable { /** * Construct a new YArray containing the specified items. * @template T * @param {Array} items * @return {YArray} */ static from(items: T_2[]): YArray; /** * @type {Array?} * @private */ private _prelimContent; get length(): number; /** * Inserts new content at an index. * * Important: This function expects an array of content. Not just a content * object. The reason for this "weirdness" is that inserting several elements * is very efficient when it is done as a single operation. * * @example * // Insert character 'a' at position 0 * yarray.insert(0, ['a']) * // Insert numbers 1, 2 at position 1 * yarray.insert(1, [1, 2]) * * @param {number} index The index to insert content at. * @param {Array} content The array of content */ insert(index: number, content: T[]): void; /** * Appends content to this YArray. * * @param {Array} content Array of content to append. */ push(content: T[]): void; /** * Preppends content to this YArray. * * @param {Array} content Array of content to preppend. */ unshift(content: T[]): void; /** * Deletes elements starting from an index. * * @param {number} index Index at which to start deleting elements * @param {number} length The number of elements to remove. Defaults to 1. */ delete(index: number, length?: number): void; /** * Returns the i-th element from a YArray. * * @param {number} index The index of the element to return from the YArray * @return {T} */ get(index: number): T; /** * Transforms this YArray to a JavaScript Array. * * @return {Array} */ toArray(): T[]; /** * Transforms this YArray to a JavaScript Array. * * @param {number} [start] * @param {number} [end] * @return {Array} */ slice(start?: number | undefined, end?: number | undefined): T[]; /** * Returns an Array with the result of calling a provided function on every * element of this YArray. * * @template T,M * @param {function(T,number,YArray):M} f Function that produces an element of the new Array * @return {Array} A new array with each element being the result of the * callback function */ map(f: (arg0: T_1, arg1: number, arg2: YArray) => M): M[]; /** * Executes a provided function on once on overy element of this YArray. * * @param {function(T,number,YArray):void} f A function to execute on every element of this YArray. */ forEach(f: (arg0: T, arg1: number, arg2: YArray) => void): void; /** * @return {IterableIterator} */ [Symbol.iterator](): IterableIterator; } export function readYArray(decoder: UpdateDecoderV1 | UpdateDecoderV2): YArray; import { YEvent } from "../utils/YEvent.js"; import { Transaction } from "../utils/Transaction.js"; import { AbstractType } from "./AbstractType.js"; import { UpdateDecoderV1 } from "../utils/UpdateDecoder.js"; import { UpdateDecoderV2 } from "../utils/UpdateDecoder.js";