new YArray()
Members
-
length
-
Computes the length of this YArray.
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)
-
Returns the i-th element from a YArray.
Parameters:
Name Type Description indexnumber The index of the element to return from the YArray
-
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 The array of content
Example
// Insert character 'a' at position 0 yarray.insert(0, ['a']) // Insert numbers 1, 2 at position 1 yarray.insert(2, [1, 2]) -
map(f) → {Array}
-
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 -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 Array of content to append.
-
toArray() → {Array}
-
Transforms this YArray to a JavaScript Array.
Returns:
Array -
toJSON() → {Array}
-
Transforms this Shared Type to a JSON object.
Returns:
Array