redux-thunk.cjs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. // src/index.ts
  20. var src_exports = {};
  21. __export(src_exports, {
  22. thunk: () => thunk,
  23. withExtraArgument: () => withExtraArgument
  24. });
  25. module.exports = __toCommonJS(src_exports);
  26. function createThunkMiddleware(extraArgument) {
  27. const middleware = ({ dispatch, getState }) => (next) => (action) => {
  28. if (typeof action === "function") {
  29. return action(dispatch, getState, extraArgument);
  30. }
  31. return next(action);
  32. };
  33. return middleware;
  34. }
  35. var thunk = createThunkMiddleware();
  36. var withExtraArgument = createThunkMiddleware;
  37. // Annotate the CommonJS export names for ESM import in node:
  38. 0 && (module.exports = {
  39. thunk,
  40. withExtraArgument
  41. });