d4be5458cc3972595096b8d655ff9c90.json 5.76 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport padStart from 'lodash/padStart'; // Countdown\n\nvar timeUnits = [['Y', 1000 * 60 * 60 * 24 * 365], ['M', 1000 * 60 * 60 * 24 * 30], ['D', 1000 * 60 * 60 * 24], ['H', 1000 * 60 * 60], ['m', 1000 * 60], ['s', 1000], ['S', 1]];\nexport function formatTimeStr(duration, format) {\n  var leftDuration = duration;\n  var escapeRegex = /\\[[^\\]]*]/g;\n  var keepList = (format.match(escapeRegex) || []).map(function (str) {\n    return str.slice(1, -1);\n  });\n  var templateText = format.replace(escapeRegex, '[]');\n  var replacedText = timeUnits.reduce(function (current, _ref) {\n    var _ref2 = _slicedToArray(_ref, 2),\n        name = _ref2[0],\n        unit = _ref2[1];\n\n    if (current.indexOf(name) !== -1) {\n      var value = Math.floor(leftDuration / unit);\n      leftDuration -= value * unit;\n      return current.replace(new RegExp(\"\".concat(name, \"+\"), 'g'), function (match) {\n        var len = match.length;\n        return padStart(value.toString(), len, '0');\n      });\n    }\n\n    return current;\n  }, templateText);\n  var index = 0;\n  return replacedText.replace(escapeRegex, function () {\n    var match = keepList[index];\n    index += 1;\n    return match;\n  });\n}\nexport function formatCountdown(value, config) {\n  var _config$format = config.format,\n      format = _config$format === void 0 ? '' : _config$format;\n  var target = new Date(value).getTime();\n  var current = Date.now();\n  var diff = Math.max(target - current, 0);\n  return formatTimeStr(diff, format);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/statistic/utils.js"],"names":["_slicedToArray","padStart","timeUnits","formatTimeStr","duration","format","leftDuration","escapeRegex","keepList","match","map","str","slice","templateText","replace","replacedText","reduce","current","_ref","_ref2","name","unit","indexOf","value","Math","floor","RegExp","concat","len","length","toString","index","formatCountdown","config","_config$format","target","Date","getTime","now","diff","max"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,sCAA3B;AACA,OAA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\";\nimport padStart from 'lodash/padStart'; // Countdown\n\nvar timeUnits = [['Y', 1000 * 60 * 60 * 24 * 365], ['M', 1000 * 60 * 60 * 24 * 30], ['D', 1000 * 60 * 60 * 24], ['H', 1000 * 60 * 60], ['m', 1000 * 60], ['s', 1000], ['S', 1]];\nexport function formatTimeStr(duration, format) {\n  var leftDuration = duration;\n  var escapeRegex = /\\[[^\\]]*]/g;\n  var keepList = (format.match(escapeRegex) || []).map(function (str) {\n    return str.slice(1, -1);\n  });\n  var templateText = format.replace(escapeRegex, '[]');\n  var replacedText = timeUnits.reduce(function (current, _ref) {\n    var _ref2 = _slicedToArray(_ref, 2),\n        name = _ref2[0],\n        unit = _ref2[1];\n\n    if (current.indexOf(name) !== -1) {\n      var value = Math.floor(leftDuration / unit);\n      leftDuration -= value * unit;\n      return current.replace(new RegExp(\"\".concat(name, \"+\"), 'g'), function (match) {\n        var len = match.length;\n        return padStart(value.toString(), len, '0');\n      });\n    }\n\n    return current;\n  }, templateText);\n  var index = 0;\n  return replacedText.replace(escapeRegex, function () {\n    var match = keepList[index];\n    index += 1;\n    return match;\n  });\n}\nexport function formatCountdown(value, config) {\n  var _config$format = config.format,\n      format = _config$format === void 0 ? '' : _config$format;\n  var target = new Date(value).getTime();\n  var current = Date.now();\n  var diff = Math.max(target - current, 0);\n  return formatTimeStr(diff, format);\n}"]},"metadata":{},"sourceType":"module"}