Skip to content

Return an item for a given identity when comparator return 0

Compare
Choose a tag to compare
@cherifGsoul cherifGsoul released this 16 Apr 19:26
· 41 commits to master since this release

Update binary search for query.index to return a range of items when the comparator returns 0 in order to return the index of item for a given identity.

For example:

var items = [
		{id: 1, name: "Item 0"},
		{id: 2, name: "Item 1"},
		{id: 3, name: "Item 1"},
		{id: 4, name: "Item 1"},
		{id: 5, name: "Item 2"}
];

var query = new BasicQuery({
         sort: "name"
});

var res = query.index({id:4, name: "Item 1"}, items); // -> 3

#33