reduxjs/reselect ? reverse-engineered prompt

Reverse engineered prompt

Build me a small TypeScript library for creating memoized selector functions, like the one Redux apps use to derive data without recomputing everything all the time.

I want a clean API where I can pass in input selectors and a result function, and get back a selector that only recalculates when its inputs change. It should work with plain JavaScript objects too, not just Redux, and it should keep returning the same result reference when nothing changed so it plays nicely with React style rendering.

Please include the main selector helpers, good TypeScript types, and a simple way to compose selectors together. Add a few examples in the docs showing how to use it with a todo list or similar state shape. If there are modern best practice details to follow, look up the current docs online and match them. Also make sure there are tests for the memoization behavior and the TypeScript types.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab