UNPKG

xe-utils

Version:

JavaScript 函数库、工具类

22 lines (18 loc) • 555 B
var helperFunctionApply = require('./helperFunctionApply') var slice = require('./slice') /** * 该方法和 setTimeout 一样的效果,区别就是支持上下文和额外参数 * * @param {Function} callback 函数 * @param {Number} wait 延迟毫秒 * @param {*} args 额外的参数 * @return {Number} */ function delay (callback, wait) { var args = slice(arguments, 2) var context = this return setTimeout(function () { helperFunctionApply(callback, context, args) }, wait) } module.exports = delay