Node-Red configuration
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.

index.js 864B

123456789101112131415161718192021222324252627282930313233343536
  1. export default (function (o, c, d) {
  2. var sortBy = function sortBy(method, dates) {
  3. if (!dates || !dates.length || !dates[0] || dates.length === 1 && !dates[0].length) {
  4. return null;
  5. }
  6. if (dates.length === 1 && dates[0].length > 0) {
  7. var _dates = dates;
  8. dates = _dates[0];
  9. }
  10. var result;
  11. var _dates2 = dates;
  12. result = _dates2[0];
  13. for (var i = 1; i < dates.length; i += 1) {
  14. if (!dates[i].isValid() || dates[i][method](result)) {
  15. result = dates[i];
  16. }
  17. }
  18. return result;
  19. };
  20. d.max = function () {
  21. var args = [].slice.call(arguments, 0); // eslint-disable-line prefer-rest-params
  22. return sortBy('isAfter', args);
  23. };
  24. d.min = function () {
  25. var args = [].slice.call(arguments, 0); // eslint-disable-line prefer-rest-params
  26. return sortBy('isBefore', args);
  27. };
  28. });