From b400d2831088ffa9760f859cf6f0c8934f86c394 Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Tue, 23 Jul 2019 03:23:22 -0500 Subject: [PATCH] Cleanup the README a bit --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ab2b3d..33bf516 100644 --- a/README.md +++ b/README.md @@ -5,21 +5,20 @@ An simple function wrapper around that queues tasks and runs them sequentially. The main purpose is to be able to run maintainance functions that are not a good fit for a web -worker context. +worker context (i.e. methods that require the DOM). # Usage Wrap your function. ``` - const task = backgroundTask(() => { - // do stuff - }); +const task = backgroundTask(() => { + // do stuff +}); ``` Call `task` as you would any other function that has no return value. The return value of a -background task is the id from `requestIdleCallback` that can be passed to `cancelIdleCallback` if -you wish to cancel the task before it runs. +background task is true if the task was queued to `requestIdleCallback` immediately or `false` if there are previous invocations queued ahead of it. + +Calling a task multiple times will queue the passed parameters and execute the task sequentially the same number of times. -Calling a task multiple times will queue the passed parameters and execute the task sequentially the -same number of times.