$ show pburtchaell/redux-promise-middleware
This is a Redux middleware library that simplifies handling asynchronous actions by intercepting actions with a promise payload and dispatching three separate actions representing the promise states: pending, fulfilled, and rejected. It supports implicit and explicit promise definitions, async functions, optimistic updates via payload.data, and custom type suffixes and delimiters. The middleware is well-structured, fully tested with a comprehensive suite covering edge cases like null/boolean/numeric resolutions, async functions, and third-party promise libraries. It is a mature, stable library with nearly 2000 stars, widely used in the Redux ecosystem. The codebase is clean and follows best practices, though it uses some older tooling versions (Babel 7, Jest 24, Webpack 4).
The LLM identified 2 files worth highlighting for reuse:
A small, self-contained utility function that checks whether a given value is a thenable (i.e., an object with a `then` method). This is a common pattern for detecting promises or promise-like objects and can be reused in any JavaScript project that needs to determine if a value is a promise.
A generic Redux middleware factory that captures each dispatched action and passes it to a spy function. This is an excellent pattern for unit testing middleware behavior: by inserting spy middleware before and after the middleware under test, you can assert that the correct actions are dispatched in the correct order. It is fully independent of the promise middleware and can be extracted for testing any Redux middleware chain.