Skip to content

isPendingJob

function isPendingJob<T>(job): boolean;

Defined in: packages/core/src/jobs/guards.ts:101

Type guard to check if a job is in pending status.

A convenience helper for checking if a job is waiting to be processed. Equivalent to job.status === JobStatus.PENDING but with better semantics.

Type ParameterDescription
TThe type of the job’s data payload
ParameterTypeDescription
jobJob<T>The job to check

boolean

true if the job status is 'pending'

const jobs = await monque.getJobs();
const pendingJobs = jobs.filter(isPendingJob);
console.log(`${pendingJobs.length} jobs waiting to be processed`);
if (isPendingJob(job)) {
  await monque.now(job.name, job.data);
}