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

mixmix

v2.1.1

Published

mixin and mingles, for multiple classes

Readme

mixmix

mix, stir, and blend; solve the problems with 'extend'

(~0.5kb, ESM version, minified & gzipped).

What it can do

  • Enable multiple inheritance for ES6 classes in Javascript (and Typescript).
  • Merge classes into one big class.
  • Instantiate the merged classes with arguments passed into the individual classes.

Installation

The recommended method using npm:

npm i mixmix

If you prefer using CDN's instead:

<!-- UMD (ES6 and above) -->
<!-- Example usage: window.mixmix() or require()... -->
<script src="https://unpkg.com/mixmix/dist/mixmix.min.js"></script>

<!-- ESM (ES6 and above) -->
<!-- Example usage: import mixmix from 'mixmix' -->
<script src="https://unpkg.com/mixmix/dist/mixmix.min.esm.js"></script>

<!-- UMD (ES5) -->
<!-- Example usage: window.mixmix() or require()... -->
<script src="https://unpkg.com/mixmix/dist/mixmix.min.es5.js"></script>

Quick Start

Initial setup:

Import it into your project if you're using node, webpack, or any package manager:

const mixmix = require('mixmix');
// OR if using ESM, `import mixmix from 'mixmix'`

These will be the example classes that will be worked on:

class Sand {
    buildCastle() {
        console.log('build build build');
    }
}
class Witch {
    castSpell() {
        console.log('cast cast cast');
    }
}

Extend multiple classes (multiple inheritance):

mixmix() is used similarly to Object.assign(), except it returns a copy of all the classes combined instead of modifying the first argument.

class Sandwich extends mixmix(Sand, Witch) {
    eat() {
        this.buildCastle();
        this.castSpell();
    }
}

Optionally, in typescript you may add an interface to get back type checking functionality:

// interface that extends the same things that is mixed
interface Sandwich extends Sand, Witch {}
class Sandwich extends mixmix(Sand, Witch) {
    // ...
}

Merge and instantiate:

mixmix() will return a new class with a modified "master" constructor that invokes all the child constructors:

const Sandwich = mixmix(Sand, Witch);
/* 
	Returns:
	
    class SandWitch {
        constructor(parametersMap: Record<ClassNameString, any[]> | any[] = null) {
            // master constructor
        }
    } 
*/

The results of the invocation will be applied to the master class's instance, which in the following case will be sandwich :

const sandwich = new Sandwich(/* parametersMap (see below) */);

The name property of the class will then be the combination of all classes:

sandwich.name
/* 
	Returns:
	
	"SandWitch"
*/

Note: This will probably not be the class variable name you will be referencing in your code, as it will more likely be the variable it's stored in (eg. const A = mixmix(A, B); A.name === 'AB').

If you would like to use the constructor of one of the classes passed in, instead of this Frankenstein's monster, you can use mixmix.withConstructorAt

const Sandwich = mixmix.withConstructorAt(0, Sand, Witch) /* (see below) */
const sandwich = new Sandwich();
// Only `Sand.constructor` is executed

API

mixmix(...class)
  • ...class: Class[]
const Sandwich = mixmix(Sand, Witch);
const sandwich = new Sandwich(/* parametersMap (see below) */);
parametersMap

Record<ClassNameString, any[]> | any[] | null | undefined

It takes in an object with the target class's name ("Sand" or "Witch") as the key, and an array with parameters to pass into its constructor as the value.

const Sandwich = mixmix(Sand, Witch);
const sandwich = new Sandwich({
    Sand: [],
    Witch: ['Son', 'of', 'a', NaN],
});
/*
	Executes:
	
	new Sand();
	new Witch('Son', 'of', 'a', NaN);
*/
mixmix.withConstructorAt(index, ...class)
  • index: number
  • ...class: Class[]
const Sandwich = mixmix.withConstructorAt(0, Sand, Witch);
const sandwich = new Sandwich(/* `...parameters` into `Sand` */);

/*
	Executes:
	
	new Sand(...parameters);
	// loop through all Witch's keys, something like this
	Sandwich.prototype[key] = Witch.prototype[key] 
*/
mixmix.withSameParamsIntoConstructors(...class)
  • ...class: Class[]
const Sandwich = mixmix.withSameParamsIntoConstructors(Sand, Witch);
const sandwich = new Sandwich(/* `...parameters` into `Sand` and `Witch` */);

/*
	Executes:
	
	new Sand(...parameters);
	new Witch(...parameters);
*/

Building/Testing

  • npm run build to build using Rollup into the "dist" folder.
  • npm run test to test using Jest with the tests in the "test" folder.

Contributing

If you find ways to make improvements (or find one of the probably many bugs), feel free to submit a pull request!