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

hops-mixin

v15.2.1

Published

Building blocks to build cusom hops mixins

Downloads

928

Readme

hops-mixin

npm

Please see the main Hops Readme for general information and a Getting Started Guide.

Contains the building blocks needed to build your own hops mixins. Mixins allow you to alter and extend Hops' functionality.

Tap into them using your own mixins and reconfigure Webpack, register additional Express middlewares and Yargs commands or fetch data to bootstrap your React application.

Please be aware that the mixin hooks are not part of the SemVer API contract. This means that hook methods and signatures can change even in minor releases. Therefore it's up to you to make sure that all hooks that you are using in your own mixins still adhere to the new implementation after an upgrade of a Hops packages.

Installation

npm install --save hops-mixin

If you don't already have an existing Hops project read this section on how to set up your first Hops project.

API

Mixin

Base class to extend from when building a mixin. Ensures the config is available in this.config.

const { Mixin } = require('hops-mixin');

class MyMixin extends Mixin {}

strategies

Strategies allow to define mixin hooks that are usable by other mixins. There are various types of strategies. callable will make the method available to other mixins. Methods with strategy pipe pass each implementation's output to the next, using the first argument as the initial value. All other arguments are being passed to all implementations as-is.

For a complete list of available strategies, have a look at the mixinable documentation.

Callable example

A mixin that exposes a method to retrieve the build config.

const {
  Mixin,
  strategies: { sync: callable },
} = require('hops-mixin');

class BuildConfigMixin extends Mixin {
  getBuildConfig() {
    return this.buildConfig;
  }
}

MyMixin.strategies = {
  getBuildConfig: callable,
};

Other mixins are now able to call the method.

const { Mixin } = require('hops-mixin');

class ConsumerMixin extends Mixin {
  myMethod() {
    const config = this.getBuildConfig();
  }
}