Registry / productivity / task-easy

task-easy

JSON →
library1.0.1jsnpmunverified

A lightweight, customizable priority queue for promise-based tasks, built on a heap data structure. Version 1.0.1 is current, with TypeScript types included. It allows developers to define custom priority logic via a comparator function. Tasks are scheduled with arguments and a priority object; the queue executes tasks in order, returning a promise for each. Lightweight alternative to bulkier job queues, ideal for in-memory async task management.

npm install task-easy
INSTALL
IMPORT
SIG · TASK-EASY
T
task-easy
productivityjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TaskEasy
import { TaskEasy } from 'task-easy'
const TaskEasy = require('task-easy')
Default export not available; named import only. CJS users must use destructuring.
TaskEasy class
import { TaskEasy } from 'task-easy'; const queue = new TaskEasy(prioritizeFn);
const queue = new TaskEasy();
Constructor requires a comparator function as first argument, optional max tasks as second.
Type definitions
import type { TaskEasy } from 'task-easy'; import { TaskEasy } from 'task-easy';
import { TaskEasy } from 'task-easy/types';
Types are bundled; no separate path needed. Use type import for type-only usage.

Creates a TaskEasy queue with a custom priority comparator, schedules five tasks with different priorities, and awaits all.

import { TaskEasy } from 'task-easy'; const prioritize = (a, b) => { if (a.priority === b.priority) { return a.timestamp < b.timestamp; } return a.priority > b.priority; }; const queue = new TaskEasy(prioritize); const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); async function main() { const promises = []; for (let i = 0; i < 5; i++) { const p = queue.schedule( delay, [100], { priority: i, timestamp: Date.now() } ); promises.push(p); } await Promise.all(promises); console.log('All tasks done'); } main().catch(console.error);
Debug
Known issues
gotchaQueue capacity default is 100 tasks; scheduling more will throw 'Queue full' error.
fix
Pass a larger maxTasks as second argument to constructor, e.g., new TaskEasy(prioritize, 500).
affects: >=1.0.0
gotchaScheduled tasks MUST return a promise; non-promise return values will cause unexpected behavior.
fix
Ensure all tasks are async functions or explicitly return a promise.
affects: >=1.0.0
gotchaComparator function must return a boolean; returning truthy/falsy values may lead to incorrect ordering.
fix
Use strict true/false returns in comparator.
affects: >=1.0.0
deprecatedMethod .schedule() expects three arguments; future versions may change signature.
fix
No immediate fix; monitor releases for changes.
affects: =1.0.1
Errors
Common errors & fixes
TypeError: task_easy_1.TaskEasy is not a constructor
Using default import incorrectly: import TaskEasy from 'task-easy'
fix
Use named import: import { TaskEasy } from 'task-easy'
Error: Queue full
Scheduling more tasks than maxTasks (default 100)
fix
Increase maxTasks in constructor or wait for tasks to complete before scheduling more
TypeError: prior is not a function
Constructor called without comparator function
fix
Pass a comparator function as first argument: new TaskEasy(prioritize)
UnhandledPromiseRejectionWarning: Error: Task must return a promise
Task function does not return a promise
fix
Ensure task is async or returns a promise explicitly
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
task-easy — npm install task-easy · libregistry