handlePortsOption.js 850 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var immutable_1 = require("immutable");
  4. function handlePortsOption(incoming) {
  5. var value = incoming.get('ports');
  6. if (!value)
  7. return [incoming, []];
  8. var obj = { min: null, max: null };
  9. if (typeof value === "string") {
  10. if (~value.indexOf(",")) {
  11. var segs = value.split(",");
  12. obj.min = parseInt(segs[0], 10);
  13. obj.max = parseInt(segs[1], 10);
  14. }
  15. else {
  16. obj.min = parseInt(value, 10);
  17. obj.max = null;
  18. }
  19. }
  20. else {
  21. obj.min = value.get("min");
  22. obj.max = value.get("max") || null;
  23. }
  24. return [incoming.set('ports', immutable_1.Map(obj)), []];
  25. }
  26. exports.handlePortsOption = handlePortsOption;
  27. //# sourceMappingURL=handlePortsOption.js.map