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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-asynq

v0.2.0

Published

Node.js client for the Asynq task queue library.

Downloads

16

Readme

node-asynq

Node.js client for the Asynq task queue library.

node-asynq allows you to produce and queue tasks in Node.js applications and consume them with Go worker servers, giving you the flexibility to use the best tool for the job.

This package aims to offer capabilities nearly identical to those of Client.

Motivation

This project serves to enhance my TypeScript and Node.js skills while contributing to the open-source community. It originated from the necessity for clients in additional languages (refer to hibiken/asynq#105).

Status

[!WARNING]

This library is currently in its early stages and may undergo frequent and potentially breaking changes. Use with caution until further stabilization.

However, contributions such as code, documentation, or testing are highly encouraged and appreciated.

Getting Started

Prerequisites

Tasks defined in your Go application. The "Basic Usage" example assumes the following Go asynq setup:

package tasks

import (
    "context"
    "encoding/json"
    "fmt"
    "log"

    "github.com/hibiken/asynq"
)

const (
    TypeEmailDelivery   = "email:deliver"
)

type EmailDeliveryPayload struct {
    UserID     int
    TemplateID string
}

func HandleEmailDeliveryTask(ctx context.Context, t *asynq.Task) error {
    var p EmailDeliveryPayload
    if err := json.Unmarshal(t.Payload(), &p); err != nil {
        return fmt.Errorf("json.Unmarshal failed: %v: %w", err, asynq.SkipRetry)
    }
    log.Printf("Sending Email to User: user_id=%d, template_id=%s", p.UserID, p.TemplateID)
    // Email delivery code ...
    return nil
}

Installation

npm install node-asynq

Basic Usage

// Import node-asynq and the relevant classes.
import { Client, Task } from "node-asynq";

// Create a Client instance to start registering tasks.
// By default, the underlying Redis broker will connect to localhost:6379.
// TODO: implement `asynq.RedisConnOpt`
const queue = new Client();

// Next, define a Task for processing.
// The first argument is the type of task,
// followed by the task's payload.
const task = new Task("email:deliver", { userId: 42, templateId: "OkcBMj" });

// Example 1: Enqueue task to be processed immediately.
await queue.enqueue(task);

// Example 2: Schedule task to be processed in the future.
// Below the task is scheduled to be processed in 5 minutes from now.
await queue.enqueue(task, { processAt: Date.now() + 1000 * 60 * 5 });

That's it! If you have the Asynqmon web UI or asynq CLI tools running, you should be able to verify the tasks were queued. Additionally and most importantly, the Go workers will be able to dequeue and process these tasks, enabling cross-platform task queueing. 🎉

License

Copyright (c) 2024 Cedric Amaya and contributors. node-asynq is free and open-source software licensed under the MIT License.