Skip to content

MapModel

Defined in: api/node/typescript/models.ts:554 ↗

MapModel provides rows that are generated by a map function based on the rows of another model.

  • NativeAdapterModel<U>

T

item type of source model that is mapped to U.

U

the type of the mapped items.

Here we have an ArrayModel holding rows of a custom interface Name and a MapModel that maps the name rows to single string rows.

interface Name {
first: string;
last: string;
}
const model = new ArrayModel<Name>([
{ first: "Hans", last: "Emil" },
{ first: "Max", last: "Mustermann" },
{ first: "Roman", last: "Tisch" },
]);
const mappedModel = new MapModel(model, (data) => data.last + ", " + data.first);
// prints "Emil, Hans"
console.log(mappedModel.rowData(0));
js

new MapModel<T, U>(sourceModel, mapFunction): MapModel<T, U>

Defined in: api/node/typescript/models.ts:566 ↗

Constructs a new MapModel that provides a mapped view on the given sourceModel by applying mapFunction on each of its rows.

Model<T>

the wrapped model.

(data) => U

maps the data from T to U. It must not modify sourceModel.

MapModel<T, U>

NativeAdapterModel<U>.constructor

readonly sourceModel: Model<T>

Defined in: api/node/typescript/models.ts:558 ↗

The source model that this MapModel maps rows from.

get [nativeModelKey](): NativeModel | undefined

Defined in: api/node/typescript/models.ts:424 ↗

NativeModel | undefined

NativeAdapterModel.[nativeModelKey]

[iterator](): Iterator<U>

Defined in: api/node/typescript/models.ts:195 ↗

Iterator<U>

NativeAdapterModel.[iterator]


filter(filterFunction): FilterModel<U>

Defined in: api/node/typescript/models.ts:118 ↗

Returns a new Model that only contains the rows of this model for which filterFunction returns true.

(data) => boolean

returns true if a row should be visible.

FilterModel<U>

a new FilterModel that wraps the current model.

NativeAdapterModel.filter


insertRow(_index, _data): void

Defined in: api/node/typescript/models.ts:191 ↗

Implementations of this function must add a row at the specified index, pushing all next rows to the right. Throws when the model rejects the modification; the default implementation always throws.

number

index of the row to insert.

U

new data item to store in a new row.

void

NativeAdapterModel.insertRow


map<U>(mapFunction): MapModel<U, U>

Defined in: api/node/typescript/models.ts:108 ↗

Returns a new Model where all elements are mapped by the function mapFunction.

U

(data) => U

maps the data from T to U.

MapModel<U, U>

a new MapModel that wraps the current model.

NativeAdapterModel.map


pushRow(data): void

Defined in: api/node/typescript/models.ts:169 ↗

Adds a line to the model with the provided data. Throws when the model rejects the modification. The default implementation calls Model.insertRow with the row count.

U

new data item to store in a new row.

void

NativeAdapterModel.pushRow


removeRow(_index): void

Defined in: api/node/typescript/models.ts:179 ↗

Implementations of this function must remove the row at the specified index. Throws when the model rejects the modification; the default implementation always throws.

number

index of the row to remove.

void

NativeAdapterModel.removeRow


reverse(): ReverseModel<U>

Defined in: api/node/typescript/models.ts:137 ↗

Returns a new Model with the same rows as this model, in reverse order.

ReverseModel<U>

a new ReverseModel that wraps the current model.

NativeAdapterModel.reverse


rowCount(): number

Defined in: api/node/typescript/models.ts:436 ↗

Returns the number of entries in the model.

number

NativeAdapterModel.rowCount


rowData(row): U | undefined

Defined in: api/node/typescript/models.ts:445 ↗

Returns the data at the specified row.

number

index in range 0..(rowCount() - 1).

U | undefined

undefined if row is out of range otherwise the data.

NativeAdapterModel.rowData


setRowData(_row, _data): void

Defined in: api/node/typescript/models.ts:583 ↗

Throws, because a MapModel can’t map a U back to the T that its source model stores.

number

U

void

NativeAdapterModel.setRowData


sort(compareFunction): SortModel<U>

Defined in: api/node/typescript/models.ts:129 ↗

Returns a new Model with the same rows as this model, ordered according to compareFunction.

(a, b) => number

compares two rows the same way the callback passed to Array.prototype.sort does.

SortModel<U>

a new SortModel that wraps the current model.

NativeAdapterModel.sort


© 2026 SixtyFPS GmbH