npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kue-helpers

v1.1.1

Published

Simple, high-level promise-based helpers for Kue (the Node.js job Queue).

Downloads

3

Readme

kue-helpers

Simple, high-level promise-based helpers for Kue (the Node.js job Queue).

yarn add kue-helpers

Usage

The default export is a function which has one required parameter: a redis url to provide to Kue. When supplied with a redis url, that function will return an object with the helper methods.

const kueHelpers = require('kue-helpers')(REDIS_URL)

kueHelpers.getQueue() // the queue object from Kue

Helper Methods

getQueue

No parameters.

Returns Kue's queue object by calling kue.createQueue.

enqueueJob

Parameters

  1. Job Name (String)
  2. Job Data (Object)

Returns a promise that executes the then on Kue's complete event, and rejects on Kue's failed event.

Example

const promise = enqueueJob('ExpensesBulkUpdate', { expenses, upsert: true })

handleResponse

Parameters:

  1. A promise
  2. The done callback from Kue's queue.process method

Example

kue.createQueue(...).process(jobName, (job, done) => {
  handleResponse(methodThatReturnsAPromise(), done)
})

processAsyncJob

Parameters:

  1. Database connection (Function). A function to get the status of the database connection. Expects an object to be returned with a property called readyState that represents that connection status of the database. A ready state of 1 means the database is connected and a ready state of anything other than 1 means that database isn't connected and will cause an error to be thrown in the job.
  2. Job Name (String)
  3. async Function

Example

processAsyncJob('ExpensesBulkUpdate', async job => {
  const { expenses, upsert } = job.data
  ... etc
})