Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
770 B

  1. 'use strict';
  2. var arrayify = require('array-ify');
  3. var dotPropGet = require('dot-prop').get;
  4. function compareFunc(prop) {
  5. return function(a, b) {
  6. var ret = 0;
  7. arrayify(prop).some(function(el) {
  8. var x;
  9. var y;
  10. if (typeof el === 'function') {
  11. x = el(a);
  12. y = el(b);
  13. } else if (typeof el === 'string') {
  14. x = dotPropGet(a, el);
  15. y = dotPropGet(b, el);
  16. } else {
  17. x = a;
  18. y = b;
  19. }
  20. if (x === y) {
  21. ret = 0;
  22. return;
  23. }
  24. if (typeof x === 'string' && typeof y === 'string') {
  25. ret = x.localeCompare(y);
  26. return ret !== 0;
  27. }
  28. ret = x < y ? -1 : 1;
  29. return true;
  30. });
  31. return ret;
  32. };
  33. }
  34. module.exports = compareFunc;