mapState.js 727 B

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