Expand all

ve.dm.FlatLinearData

Extends

Constructor

new ve.dm.FlatLinearData(store, [data]) #

Flat linear data storage

Parameters:

Name Type Attributes Description
store ve.dm.HashValueStore

Hash-value store

data Array optional

Linear data

Source:
Flat linear data storage

Methods

batchSplice(offset, remove, data) → {Array} #

Returns ve.batchSplice of linear data

Parameters:

Name Type Description
offset number
remove number
data Array
Inherited from:
Source:
See:

Returns:

Type
Array
Returns ve.batchSplice of linear data

batchSpliceObject(offset, remove, data) → {ve.dm.LinearData} #

Returns ve.batchSplice of linear data, wrapped in a LinearData object

Parameters:

Name Type Description
offset number
remove number
data Array
Inherited from:
Source:
See:

Returns:

Type
ve.dm.LinearData
Returns ve.batchSplice of linear data, wrapped in a LinearData object

containsElementData() → {boolean} #

Check for elements in data.

This method assumes that any value that has a type property that's a string is an element object. Elements are discovered by iterating through the entire data array (backwards).

Source:

Returns:

At least one elements exists in data

Type
boolean
Check for elements in data.

getData([offset]) → {Object|Array} #

Gets linear data from a specified index, or all data if no index specified

Parameters:

Name Type Attributes Description
offset number optional

Offset to get data from

Inherited from:
Source:

Returns:

Data from index, or all data (by reference)

Type
Object | Array
Gets linear data from a specified index, or all data if no index specified

getDataSlice([range], [deep]) → {Array} #

Get a slice or copy of the provided data.

Parameters:

Name Type Attributes Default Description
range ve.Range optional

Range of data to get, all data will be given by default

deep boolean optional
false

Whether to return a deep copy (WARNING! This may be very slow)

Inherited from:
Source:

Returns:

Slice or copy of data

Type
Array
Get a slice or copy of the provided data.

getLength() → {number} #

Gets length of the linear data

Inherited from:
Source:

Returns:

Length of the linear data

Type
number
Gets length of the linear data

getStore() → {ve.dm.HashValueStore} #

Gets the hash-value store

Inherited from:
Source:

Returns:

The hash-value store

Type
ve.dm.HashValueStore
Gets the hash-value store

getType(offset) → {string} #

Get the type of the element at a specified offset.

Parameters:

Name Type Description
offset number

Data offset

Source:

Returns:

Type of the element

Type
string
Get the type of the element at a specified offset.

isCloseElementData(offset) → {boolean} #

Checks if data at a given offset is a close element.

Parameters:

Name Type Description
offset number

Data offset

Source:

Returns:

Data at offset is a close element

Type
boolean
Checks if data at a given offset is a close element.

isElementData(offset) → {boolean} #

Check if data at a given offset is an element.

Parameters:

Name Type Description
offset number

Data offset

Source:

Returns:

Data at offset is an element

Type
boolean
Check if data at a given offset is an element.

isOpenElementData(offset) → {boolean} #

Checks if data at a given offset is an open element.

Parameters:

Name Type Description
offset number

Data offset

Source:

Returns:

Data at offset is an open element

Type
boolean
Checks if data at a given offset is an open element.

modifyData(offset, modify) #

Modify an existing object in the linear model

As objects in the model and immutable, this creates a clone which is passed to a callback function for modification, then the clone is inserted into the model.

Parameters:

Name Type Description
offset number

Offset to modify data at

modify function

Modification function. First argument is the data element to modify.

Inherited from:
Source:

Modify an existing object in the linear model

As objects in the model and immutable, this creates a clone which is passed to a callback function for modification, then the clone is inserted into the model.

push([…values]) → {number} #

Push data to the end of the array

Parameters:

Name Type Attributes Description
values Object optional
repeatable

Values to store

Inherited from:
Source:

Returns:

The new length of the linear data

Type
number
Push data to the end of the array

setData(offset, value) #

Sets linear data at a specified index

Parameters:

Name Type Description
offset number

Offset to set data at

value Object | string

Value to store

Inherited from:
Source:
Sets linear data at a specified index

slice(begin, [end]) → {Array} #

Slice linear data

Parameters:

Name Type Attributes Description
begin number

Index to begin at

end number optional

Index to end at

Inherited from:
Source:

Returns:

One-level deep copy of sliced range

Type
Array
Slice linear data

sliceObject(begin, [end]) → {ve.dm.LinearData} #

Slice linear data and return new LinearData object containing result

Parameters:

Name Type Attributes Description
begin number

Index to begin at

end number optional

Index to end at

Inherited from:
Source:

Returns:

LinearData object containing one-level deep copy of sliced range

Type
ve.dm.LinearData
Slice linear data and return new LinearData object containing result

splice(index, deleteCount, […elements]) → {Array} #

Splice linear data

Parameters:

Name Type Attributes Description
index number

Splice from

deleteCount number

Items to be removed

elements Object optional
repeatable

Items to be inserted

Inherited from:
Source:

Returns:

Elements removed

Type
Array
Splice linear data

spliceObject(index, deleteCount, […elements]) → {ve.dm.LinearData} #

Splice linear data and return new LinearData object containing result

Parameters:

Name Type Attributes Description
index number

Splice from

deleteCount number

Items to be removed

elements Object optional
repeatable

Items to be inserted

Inherited from:
Source:

Returns:

LinearData object containing elements removed

Type
ve.dm.LinearData
Splice linear data and return new LinearData object containing result