Sha256: 5ef5dbc048fc083c87c750056139a460ce9514875df3e6a6a834859d47a5a68d
Contents?: true
Size: 717 Bytes
Versions: 44
Compression:
Stored size: 717 Bytes
Contents
/** * Returns a function, that, as long as it continues to be invoked, will not * be triggered. The function will be called after it stops being called for * N milliseconds. * @param {Object} context - the context for the called function. * @param {Function} func - the function to be executed. * @param {int} wait - number of milliseconds to wait before executing the function. * @private * @returns {Void} - Returns nothing. */ export default function delayed(context, func, wait) { let timeout = null; return function(...args) { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => { timeout = null; Reflect.apply(func, context, args); }, wait); } }
Version data entries
44 entries across 44 versions & 1 rubygems