utils.js 735 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.times = times;
  4. exports.getTrueValue = getTrueValue;
  5. exports.getMonthEndDay = getMonthEndDay;
  6. var _number = require("../utils/validate/number");
  7. function times(n, iteratee) {
  8. if (n < 0) {
  9. return [];
  10. }
  11. var index = -1;
  12. var result = Array(n);
  13. while (++index < n) {
  14. result[index] = iteratee(index);
  15. }
  16. return result;
  17. }
  18. function getTrueValue(value) {
  19. if (!value) {
  20. return 0;
  21. }
  22. while ((0, _number.isNaN)(parseInt(value, 10))) {
  23. if (value.length > 1) {
  24. value = value.slice(1);
  25. } else {
  26. return 0;
  27. }
  28. }
  29. return parseInt(value, 10);
  30. }
  31. function getMonthEndDay(year, month) {
  32. return 32 - new Date(year, month - 1, 32).getDate();
  33. }