index
algebra.index(set, items, item)
Returns where item
should be inserted into items
which is represented by set
.
algebra = new set.Algebra(
set.props.sort("orderBy")
);
algebra.index(
{orderBy: "age"},
[{id: 1, age: 3},{id: 2, age: 5},{id: 3, age: 8},{id: 4, age: 10}],
{id: 6, age: 3}
) //-> 2
The default sort property is what is specified by id. This means if that if the sort property is not specified, it will assume the set is sorted by the specified id property.
Parameters
- set
{Set}
:The
set
that describesitems
. - items
{Array<Object>}
:An array of data objects.
- item
{Object}
:The data object to be inserted.
Returns
{Number}
:
The position to insert item
.