{"size": 1399, "ext": "js", "max_stars_repo_path": "miniprogram/utils/util.js", "max_stars_repo_name": "Doubiiu/HowCourses", "max_stars_repo_stars_event_min_datetime": "2020-04-29T09:23:56.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-29T09:23:56.000Z", "max_issues_repo_path": "miniprogram/utils/util.js", "max_issues_repo_name": "Doubiiu/HowCourses", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "miniprogram/utils/util.js", "max_forks_repo_name": "Doubiiu/HowCourses", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.9857142857, "max_line_length": 114, "alphanum_fraction": 0.5997140815}
function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()


  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}

module.exports = {
  formatTime: formatTime
};

var course = require('../fakedata/course.js')

function getData(url) {
  return new Promise(function (resolve, reject) {
    wx.request({
      url: url,
      data: {},
      header: {
        //'Content-Type': 'application/json'
      },
      success: function (res) {
        console.log("success")
        resolve(res)
      },
      fail: function (res) {
        reject(res)
        console.log("failed")
      }
    })
  })
}

function getData2() {
  return course.index;
}

module.exports.getData = getData;
module.exports.getData2 = getData2;

function throttle(fn, gapTime) {
  if (gapTime == null || gapTime == undefined) {
    gapTime = 1500
  }

  let _lastTime = null

  // 返回新的函数
  return function () {
    let _nowTime = + new Date()
    if (_nowTime - _lastTime > gapTime || !_lastTime) {
      fn.apply(this, arguments)   //将this和参数传给原函数
      _lastTime = _nowTime
    }
  }
}
module.exports = {
  throttle: throttle
}