Expand all

ve.dm.LinearData

Constructor

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

Generic linear data storage

Parameters:

Name Type Attributes Description
store ve.dm.HashValueStore

Hash-value store

data Array optional

Linear data

Source:
Generic 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
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
Source:
See:

Returns:

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

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

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)

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

Source:

Returns:

Length of the linear data

Type
number
Gets length of the linear data

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

Gets the hash-value store

Source:

Returns:

The hash-value store

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

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.

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

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

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

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

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

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

Source:

Returns:

LinearData object containing elements removed

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

getType(item) → {string}static #

Get the type of an element

This will return the same string for close and open elements.

Parameters:

Name Type Description
item Object

Element item

Source:

Returns:

Type of the element

Type
string

Get the type of an element

This will return the same string for close and open elements.

isCloseElementData(item) → {boolean}static #

Checks if data item is a close element.

Parameters:

Name Type Description
item Object

Element item

Source:

Returns:

Item is a close element

Type
boolean
Checks if data item is a close element.

isElementData(item) → {boolean}static #

Check if data item is an element.

This method assumes that any value that has a type property that's a string is an element object.

Element data:

 <heading> a </heading> <paragraph> b c <img></img> </paragraph>
^         . ^          ^           . . ^     ^     ^            .

Parameters:

Name Type Description
item Object | Array | string

Linear data item

Source:

Returns:

Item is an element

Type
boolean
Check if data item is an element.

isOpenElementData(item) → {boolean}static #

Checks if data item is an open element.

Parameters:

Name Type Description
item Object

Element item

Source:

Returns:

Item is an open element

Type
boolean
Checks if data item is an open element.