parse-path.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var lodash_es_1 = require("lodash-es");
  4. var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi;
  5. var regexDot = /[^\s\,]+/gi;
  6. function parsePath(p) {
  7. var path = p || [];
  8. if (lodash_es_1.isArray(path)) {
  9. return path;
  10. }
  11. if (lodash_es_1.isString(path)) {
  12. path = path.match(regexTags);
  13. lodash_es_1.each(path, function (item, index) {
  14. // @ts-ignore
  15. item = item.match(regexDot);
  16. if (item[0].length > 1) {
  17. var tag = item[0].charAt(0);
  18. // @ts-ignore
  19. item.splice(1, 0, item[0].substr(1));
  20. // @ts-ignore
  21. item[0] = tag;
  22. }
  23. // @ts-ignore
  24. lodash_es_1.each(item, function (sub, i) {
  25. // @ts-ignore
  26. if (!isNaN(sub)) {
  27. // @ts-ignore
  28. item[i] = +sub;
  29. }
  30. });
  31. // @ts-ignore
  32. path[index] = item;
  33. });
  34. return path;
  35. }
  36. }
  37. exports.default = parsePath;
  38. //# sourceMappingURL=parse-path.js.map