underscore-query
underscore-query copied to clipboard
Data Indexes
Something like this probably makes more sense on a library like Backbone query with more granular control of the data structure (BB model). However I'm curious @davidgtonge about your opinion on the possibly supporting built indexes.
Yeah - I implemented something like this in backbone query. I'm doing a lot more functional stuff now, so my preference is to use memoization.
Here is some WIP code to add memoized filtering and sorting for arrays: https://github.com/davidgtonge/query-predicate/blob/master/src/utils/sort.js
Essentially you prime the cache by running a load of queries - you can then filter the array using a combination of queries - and the performance should be really good.
I'm putting together a proof of concept using data from the Land Registry (hundreds of thousands of records).