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

guac-hoc

v0.1.0

Published

General Usage Advanced Components (guac) - A higher order component (HOC) and utility library.

Readme

GUAC-HOC

WrappedComponent = higherOrderComponent1(higherOrderComponent2(WrappedComponent));
...
<WrappedComponent className='myClassName'/>

An example implementation is below. Notice the problem with className. Imagine that, as an end user, I define a component, apply the higher order component, then want to pass in a className prop. This higher order component would intercept it! Note that this is an issue with every prop, including event props such as onClick and onMouseDown. While it is possible to solve this with composition from the library manager's end, this can lead to ugly code and excessive boilerplate.

  function higherOrderComponent1(WrappedComponent) {  
    ...  
    return class WrapperComponent extends React.Component {  
      ...
      render() {
        return (
          /* className is intercepted and overridden, so some user-passed props 
          like className are not propagated to WrappedComponent*/
          <WrappedComponent {...this.props} className='styleClass1'/>
        );
      }
    }
  }

So instead, we let this library handle it.

  function higherOrderComponent(WrappedComponent) {
  ...  
    class WrapperComponent extends React.Component {
      constructor() {
        super();
        //Instead of following ES6 experimental structure, use this to have more java-like declarative syntax.
        this.bindAllMethods();
      }
      ...
      render() {
        return (
                                                     /* \/ Call this to retrieve the composed classNames.*/
          <WrappedComponent {...this.props} className={this.className()}/>
        );
      }
      //This line provides higher-order-component functionality to your components.
      return HOC(WrapperComponent);
    }
  }
npm install --save guac-hoc@latest
import HOC from 'guac-hoc/lib/HOC';
import Guac from 'guac-hoc/lib/Guac';

Method|Parameters|Returns|Description ---|---|---|--- this.bindAllMethods()|None|None|Use in constructor. Binds all class methods to the instance. this.deleteUsedProps(propNames)|propNames: list<string>|props: object|Removes all props that you do not want exposed to your WrappedComponent.

These methods are special, reserved methods that each map to a prop. If your higher-order component intercepts or passes down any of these props to the WrappedComponent, instead implement the corresponding method and pass it or its return value down instead.

Method|Parameters|Returns|Description ---|---|---|--- this.className()|None|string|Define the calculation for your higher-order component's className here and return it. Call this in render() to get the composed className and pass that value down. this.onClick(event)|event|None|Define onClick prop. Pass prop as a method reference as usual. this.onMouseDown(event)|event|None|Define onMouseDown prop. Pass prop as a method reference as usual. this.onMouseUp(event)|event|None|Define onMouseUp prop. Pass prop as a method reference as usual. this.onMouseEnter(event)|event|None|Define onMouseEnter prop. Pass prop as a method reference as usual. this.onMouseLeave(event)|event|None|Define onMouseLeave prop. Pass prop as a method reference as usual.