mapState.js 816 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var _tslib = require('./_virtual/_tslib.js');
  4. var utils = require('./utils.js');
  5. function mapState(stateMap, stateId) {
  6. var e_1, _a;
  7. var foundStateId;
  8. try {
  9. for (var _b = _tslib.__values(Object.keys(stateMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
  10. var mappedStateId = _c.value;
  11. if (utils.matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
  12. foundStateId = mappedStateId;
  13. }
  14. }
  15. } catch (e_1_1) {
  16. e_1 = {
  17. error: e_1_1
  18. };
  19. } finally {
  20. try {
  21. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  22. } finally {
  23. if (e_1) throw e_1.error;
  24. }
  25. }
  26. return stateMap[foundStateId];
  27. }
  28. exports.mapState = mapState;