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

wither

v0.1.1

Published

a feature-full decorating library for javascript

Downloads

11

Readme

Wither

A feature-full decorator library for node.js

###handle(func, [type], handler) type is optional and can be:

  • Name of a precondition
  • Error Type

Wrap functions with error handling logic.
This allows you to separate the meat of your function from your error handling.

function getElement(array, index){
  return array[index];
}

getElement = wither.handle(getElement, TypeError, function(e, array, index){
  console.log("Caught: " + e.message);
});

getElement(undefined, 4); // Caught: Cannot read property '4' of undefined

As you can see, the original arguments are still accessible in the handler. In this example we've specified the kind of error we want to catch. This means that only TypeErrors will be caught with this function. Other errors will fall through.

###before(func, before)

function doSomething(){
  console.log("Something!");
}

doSomething = wither.before(doSomething, function(){
  console.log(arguments.callee.name + " called with (" + Array.prototype.slice(arguments) + ")");
});

doSomething(1,2,'a'); //doSomething called with (1,2,'a')
                      //Something!

###after(func, after)

function doSomething(){
  console.log("Something!");
}

doSomething = wither.after(doSomething, function(){
  console.log("DONE!");
});

doSomething(); // Something!
               // DONE!

###pre(func, [name], condition) Throws an error if condition returns false. This error can be caught with a handle

function divide(a, b){
  return a/b;
}

divide = wither.pre(divide, 'not-zero', function(a, b){
  return a != 0;
});

divide = wither.handle(divide, 'not-zero', function(e, a, b){
  console.log("Everything is not shiny!")
});

divide(1/0); // Everything is not shiny!;

###post(func, [name], condition)

function add(a, b) //always returns two
  return a + b;
}

add = wither.post(add, 'two', function(ret, args){
  return ret == 2;
}

add = wither.handle(add, 'two', function(a,b){
  console.log("Sum of " + a + " and " + b + " is not 2!");
});

add(1,2); // Sum of 1 and 2 is not 2!