map.mjs 753 B

1234567891011121314151617181920212223242526
  1. import { parseDef } from "../parseDef.mjs";
  2. import { parseRecordDef } from "./record.mjs";
  3. export function parseMapDef(def, refs) {
  4. if (refs.mapStrategy === 'record') {
  5. return parseRecordDef(def, refs);
  6. }
  7. const keys = parseDef(def.keyType._def, {
  8. ...refs,
  9. currentPath: [...refs.currentPath, 'items', 'items', '0'],
  10. }) || {};
  11. const values = parseDef(def.valueType._def, {
  12. ...refs,
  13. currentPath: [...refs.currentPath, 'items', 'items', '1'],
  14. }) || {};
  15. return {
  16. type: 'array',
  17. maxItems: 125,
  18. items: {
  19. type: 'array',
  20. items: [keys, values],
  21. minItems: 2,
  22. maxItems: 2,
  23. },
  24. };
  25. }
  26. //# sourceMappingURL=map.mjs.map