项目原始demo,不改动
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.
 
 
 
 

37 rindas
868 B

  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = function compareLocations(a, b) {
  7. if(typeof a === "string") {
  8. if(typeof b === "string") {
  9. if(a < b) return -1;
  10. if(a > b) return 1;
  11. return 0;
  12. } else if(typeof b === "object") {
  13. return 1;
  14. } else {
  15. return 0;
  16. }
  17. } else if(typeof a === "object") {
  18. if(typeof b === "string") {
  19. return -1;
  20. } else if(typeof b === "object") {
  21. if(a.start && b.start) {
  22. const ap = a.start;
  23. const bp = b.start;
  24. if(ap.line < bp.line) return -1;
  25. if(ap.line > bp.line) return 1;
  26. if(ap.column < bp.column) return -1;
  27. if(ap.column > bp.column) return 1;
  28. }
  29. if(a.index < b.index) return -1;
  30. if(a.index > b.index) return 1;
  31. return 0;
  32. } else {
  33. return 0;
  34. }
  35. }
  36. };