const collection = new Collection<Readonly<{
name: string,
age: number,
}>>();
// Ensure all names are unique
const ixUniqueNames = collection.registerIndex(
premap(
p.name,
uniqueHashIndex()
)
);
// Maintain the number of adults
const ixAdultCount = collection.registerIndex(
premap(
p => p.age >= 18 ? p : undefined,
countIndex()
)
);
console.log(ixAdultCount.get().value);
Generated using TypeDoc
Passes inputs through a function before handing them to the given index. If the function returns
undefined
, the input is ignored.