index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1662612701779, function(require, module, exports) {
  8. /**
  9. * Helpers.
  10. */
  11. var s = 1000;
  12. var m = s * 60;
  13. var h = m * 60;
  14. var d = h * 24;
  15. var y = d * 365.25;
  16. /**
  17. * Parse or format the given `val`.
  18. *
  19. * Options:
  20. *
  21. * - `long` verbose formatting [false]
  22. *
  23. * @param {String|Number} val
  24. * @param {Object} [options]
  25. * @throws {Error} throw an error if val is not a non-empty string or a number
  26. * @return {String|Number}
  27. * @api public
  28. */
  29. module.exports = function(val, options) {
  30. options = options || {};
  31. var type = typeof val;
  32. if (type === 'string' && val.length > 0) {
  33. return parse(val);
  34. } else if (type === 'number' && isNaN(val) === false) {
  35. return options.long ? fmtLong(val) : fmtShort(val);
  36. }
  37. throw new Error(
  38. 'val is not a non-empty string or a valid number. val=' +
  39. JSON.stringify(val)
  40. );
  41. };
  42. /**
  43. * Parse the given `str` and return milliseconds.
  44. *
  45. * @param {String} str
  46. * @return {Number}
  47. * @api private
  48. */
  49. function parse(str) {
  50. str = String(str);
  51. if (str.length > 100) {
  52. return;
  53. }
  54. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
  55. str
  56. );
  57. if (!match) {
  58. return;
  59. }
  60. var n = parseFloat(match[1]);
  61. var type = (match[2] || 'ms').toLowerCase();
  62. switch (type) {
  63. case 'years':
  64. case 'year':
  65. case 'yrs':
  66. case 'yr':
  67. case 'y':
  68. return n * y;
  69. case 'days':
  70. case 'day':
  71. case 'd':
  72. return n * d;
  73. case 'hours':
  74. case 'hour':
  75. case 'hrs':
  76. case 'hr':
  77. case 'h':
  78. return n * h;
  79. case 'minutes':
  80. case 'minute':
  81. case 'mins':
  82. case 'min':
  83. case 'm':
  84. return n * m;
  85. case 'seconds':
  86. case 'second':
  87. case 'secs':
  88. case 'sec':
  89. case 's':
  90. return n * s;
  91. case 'milliseconds':
  92. case 'millisecond':
  93. case 'msecs':
  94. case 'msec':
  95. case 'ms':
  96. return n;
  97. default:
  98. return undefined;
  99. }
  100. }
  101. /**
  102. * Short format for `ms`.
  103. *
  104. * @param {Number} ms
  105. * @return {String}
  106. * @api private
  107. */
  108. function fmtShort(ms) {
  109. if (ms >= d) {
  110. return Math.round(ms / d) + 'd';
  111. }
  112. if (ms >= h) {
  113. return Math.round(ms / h) + 'h';
  114. }
  115. if (ms >= m) {
  116. return Math.round(ms / m) + 'm';
  117. }
  118. if (ms >= s) {
  119. return Math.round(ms / s) + 's';
  120. }
  121. return ms + 'ms';
  122. }
  123. /**
  124. * Long format for `ms`.
  125. *
  126. * @param {Number} ms
  127. * @return {String}
  128. * @api private
  129. */
  130. function fmtLong(ms) {
  131. return plural(ms, d, 'day') ||
  132. plural(ms, h, 'hour') ||
  133. plural(ms, m, 'minute') ||
  134. plural(ms, s, 'second') ||
  135. ms + ' ms';
  136. }
  137. /**
  138. * Pluralization helper.
  139. */
  140. function plural(ms, n, name) {
  141. if (ms < n) {
  142. return;
  143. }
  144. if (ms < n * 1.5) {
  145. return Math.floor(ms / n) + ' ' + name;
  146. }
  147. return Math.ceil(ms / n) + ' ' + name + 's';
  148. }
  149. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  150. return __REQUIRE__(1662612701779);
  151. })()
  152. //miniprogram-npm-outsideDeps=[]
  153. //# sourceMappingURL=index.js.map