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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hybrid-callback

v1.0.1

Published

A very simple node.js hybrid callback pattern library

Downloads

11

Readme

hybrid-callback - A very simple node.js hybrid callback pattern library

NPM

Build Status Coverage Status

What is it

Node.js has the async programming model. Most of the function calls have the last parameter as a callback parameter, which is a function reference. Usually you have to deal with each callback's error/success state, this duplicates code a lot and creates the callback hell.

There are different options to deal with callbacks including promises. hybrid-callback is a very simple pattern where you wrap the callback with a function call. Wraping the callback will allow you to write your code for success states only and error states will bubble up as needed.

Getting started

$ npm install --save hybrid-callback

Usage

Instead of writing

function f1(data, cb) {
  f2(data, function(err, data) {
    if(err) {
      return cb(err); // Each Async function/block needs to check for errors
    }
    else {
      doSomethingInDb(data, function(err, data) {
        if(err) { // Deal with error
          return cb(err);
        }
        else {
          processData(data, function(err, finalData) {
            if(err) {  // Deal with errors in every step, a lot of repeated code, chance to introduce bugs.
              return cb(err);
            }
            else {
              cb(null, finalData);
            }
          });
        }
      });
    }
  });
}

Write

const hcb = require("hybrid-callback");

function f1(data, cb) {
  f2(data, hcb(cb, function(data) { // Wrap your cb with hcb, handle the success state only
    doSomethingInDb(data, hcb(cb, function(data) { // Any error state along the way will bubble up automatically 
      processData(data, hcb(cb, function(finalData) {
        cb(null, finalData); // Simpler code, more readable, less bugs from error handling
      }));
    }));
  }));
}

License

hybrid-callback is licensed under the MIT.

Changelog

  • 1.0.0: Initial version (simplified from cb-result library)