new YArray()
- Implements:
- IterableIterator.<T>
Extends
- AbstractType.<YArrayEvent.<T>>
Methods
-
delete(index, length)
-
Deletes elements starting from an index.
Parameters:
Name Type Default Description indexnumber Index at which to start deleting elements
lengthnumber 1 The number of elements to remove. Defaults to 1.
-
forEach(f)
-
Executes a provided function on once on overy element of this YArray.
Parameters:
Name Type Description ffunction A function to execute on every element of this YArray.
-
get(index) → {T}
-
Returns the i-th element from a YArray.
Parameters:
Name Type Description indexnumber The index of the element to return from the YArray
Returns:
T -
insert(index, content)
-
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.
Parameters:
Name Type Description indexnumber The index to insert content at.
contentArray.<T> The array of content
Example
// Insert character 'a' at position 0 yarray.insert(0, ['a']) // Insert numbers 1, 2 at position 1 yarray.insert(1, [1, 2]) -
map(f) → {Array.<M>}
-
Returns an Array with the result of calling a provided function on every element of this YArray.
Parameters:
Name Type Description ffunction Function that produces an element of the new Array
Returns:
Array.<M> -A new array with each element being the result of the callback function
-
push(content)
-
Appends content to this YArray.
Parameters:
Name Type Description contentArray.<T> Array of content to append.
-
Symbol.iterator() → {IterableIterator.<T>}
-
Returns:
IterableIterator.<T> -
toArray() → {Array.<T>}
-
Transforms this YArray to a JavaScript Array.
Returns:
Array.<T> -
toJSON() → {Array.<any>}
-
Transforms this Shared Type to a JSON object.
Returns:
Array.<any>