Comparing version 0.1.1 to 0.2.0
@@ -23,3 +23,3 @@ "use strict"; | ||
while (debouncedTasks.length) { | ||
var task = scheduledExcuteDebouncedTasks.shift(); | ||
var task = debouncedTasks.shift(); | ||
task.fn.apply(task, task.args); | ||
@@ -26,0 +26,0 @@ } |
@@ -16,3 +16,5 @@ "use strict"; | ||
} | ||
scheduled = util_1.schedule(function () { return throttledFn.apply(void 0, args); }); | ||
scheduled = util_1.schedule(function throttledExecution() { | ||
throttledFn.apply(void 0, args); | ||
}); | ||
}; | ||
@@ -19,0 +21,0 @@ })(throttledFn); |
@@ -5,8 +5,8 @@ "use strict"; | ||
if (typeof w.requestIdleCallback === 'function') { | ||
exports.schedule = w.requestIdleCallback; | ||
exports.unschedule = w.cancelIdleCallback; | ||
exports.schedule = w.requestIdleCallback.bind(w); | ||
exports.unschedule = w.cancelIdleCallback.bind(w); | ||
} | ||
else if (typeof w.requestAnimationFrame === 'function') { | ||
exports.schedule = w.requestAnimationFrame; | ||
exports.unschedule = w.cancelAnimationFrame; | ||
exports.schedule = w.requestAnimationFrame.bind(w); | ||
exports.unschedule = w.cancelAnimationFrame.bind(w); | ||
} | ||
@@ -13,0 +13,0 @@ else { |
{ | ||
"name": "idley", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Helper functions for implementing the idle-until-urgent pattern", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/yosbelms/idley.git", |
@@ -19,3 +19,3 @@ import { schedule, unschedule } from './util' | ||
while (debouncedTasks.length) { | ||
const task = scheduledExcuteDebouncedTasks.shift() | ||
const task = debouncedTasks.shift() | ||
task.fn(...task.args) | ||
@@ -22,0 +22,0 @@ } |
@@ -11,5 +11,7 @@ import { schedule, unschedule } from './util' | ||
} | ||
scheduled = schedule(() => throttledFn(...args)) | ||
scheduled = schedule(function throttledExecution() { | ||
throttledFn(...args) | ||
}) | ||
} | ||
})(throttledFn) | ||
} |
@@ -6,7 +6,7 @@ let w: any = window | ||
if (typeof w.requestIdleCallback === 'function') { | ||
schedule = w.requestIdleCallback | ||
unschedule = w.cancelIdleCallback | ||
schedule = w.requestIdleCallback.bind(w) | ||
unschedule = w.cancelIdleCallback.bind(w) | ||
} else if (typeof w.requestAnimationFrame === 'function') { | ||
schedule = w.requestAnimationFrame | ||
unschedule = w.cancelAnimationFrame | ||
schedule = w.requestAnimationFrame.bind(w) | ||
unschedule = w.cancelAnimationFrame.bind(w) | ||
} else { | ||
@@ -13,0 +13,0 @@ schedule = function _setTimeout(fn) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15451
234