Skip to content

Commit

Permalink
Fix addTask to insert new tasks in correct order (fixes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Jul 22, 2019
1 parent f9ec76f commit 6e8a1fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cronosjs",
"version": "1.2.0",
"version": "1.2.1",
"description": "A cron based task scheduler for node and the browser, with extended syntax and timezone support.",
"keywords": [
"cron",
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let runningTimer: number | null = null
function addTask(task: CronosTask) {
if (task['_timestamp']) {
const insertIndex = scheduledTasks.findIndex(t => (t['_timestamp'] || 0) < (task['_timestamp'] || 0))
if (insertIndex >= 0) scheduledTasks.splice(insertIndex + 1, 0, task)
if (insertIndex >= 0) scheduledTasks.splice(insertIndex, 0, task)
else scheduledTasks.push(task)
}
}
Expand Down

0 comments on commit 6e8a1fe

Please sign in to comment.