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

@pixielity/ts-mixins

v1.0.0

Published

A powerful TypeScript mixin library with full type safety, decorator support, and flexible configuration

Readme

TS Mixins

npm version License: MIT Build Status Coverage Status

A powerful TypeScript mixin library with full type safety, decorator support, and flexible configuration.

Features

  • 🔒 Type-safe: Full TypeScript support with proper type inference
  • 🧩 Flexible: Mix any number of classes with different strategies
  • 🎭 Decorator support: Inherit decorators from constituent classes
  • ⚙️ Configurable: Choose between different mixing strategies
  • 🔍 Tracking: Track and detect mixins at runtime
  • 🏗️ Abstract class support: Mix abstract classes with concrete implementations

Installation

```bash

npm

npm install ts-mixins

yarn

yarn add ts-mixins

pnpm

pnpm add ts-mixins ```

Basic Usage

```typescript import { Mixin } from 'ts-mixins';

// Define your classes class Logger { log(message: string) { console.log([LOG]: ${message}); } }

class Serializable { serialize() { return JSON.stringify(this); } }

// Create a mixed class const LoggableSerializable = Mixin(Logger, Serializable);

// Use the mixed class const instance = new LoggableSerializable(); instance.log('Hello, world!'); // [LOG]: Hello, world! console.log(instance.serialize()); // {"message":"Hello, world!"} ```

Using the Decorator

```typescript import { Mix } from 'ts-mixins';

class Logger { log(message: string) { console.log([LOG]: ${message}); } }

class Serializable { serialize() { return JSON.stringify(this); } }

@Mix(Logger, Serializable) class User { name: string;

constructor(name: string) { this.name = name; } }

const user = new User('John'); user.log('User created'); // [LOG]: User created console.log(user.serialize()); // {"name":"John"} ```

Configuration

TS Mixins provides several configuration options to customize its behavior:

```typescript import { settings } from 'ts-mixins';

// Configure initialization function settings.initFunction = 'initialize';

// Configure prototype strategy settings.prototypeStrategy = 'proxy'; // 'copy' (default) or 'proxy'

// Configure statics strategy settings.staticsStrategy = 'proxy'; // 'copy' (default) or 'proxy'

// Configure decorator inheritance settings.decoratorInheritance = 'direct'; // 'deep' (default), 'direct', or 'none' ```

Configuration Options

| Option | Description | Default | Values | | ---------------------- | -------------------------------------------------------- | -------- | --------------------------------- | | initFunction | Name of the initialization function to call after mixing | null | string or null | | prototypeStrategy | Strategy for handling prototype properties | 'copy' | 'copy' or 'proxy' | | staticsStrategy | Strategy for handling static properties | 'copy' | 'copy' or 'proxy' | | decoratorInheritance | Strategy for inheriting decorators | 'deep' | 'deep', 'direct', or 'none' |

Advanced Usage

Working with Abstract Classes

```typescript import { Mixin } from 'ts-mixins';

abstract class Entity { id: string;

constructor(id: string) { this.id = id; }

abstract getType(): string; }

class Product { name: string; price: number;

constructor(name: string, price: number) { this.name = name; this.price = price; }

getType(): string { return 'Product'; } }

const EntityProduct = Mixin(Entity, Product);

const product = new EntityProduct('abc123', 'Laptop', 999); console.log(product.id); // abc123 console.log(product.name); // Laptop console.log(product.getType()); // Product ```

Tracking Mixins

```typescript import { Mixin, hasMixin, getMixinsForClass } from 'ts-mixins';

class A { methodA() { return 'A'; } }

class B { methodB() { return 'B'; } }

const AB = Mixin(A, B); const instance = new AB();

// Check if an instance has a specific mixin console.log(hasMixin(instance, A)); // true console.log(hasMixin(instance, B)); // true

// Get all mixins for a class const mixins = getMixinsForClass(AB); console.log(mixins); // [A, B] ```

Decorator Inheritance

```typescript import { Mixin, Decorate } from 'ts-mixins';

function LogClass(target: any) { console.log(Class ${target.name} was decorated); return target; }

function LogProperty(target: any, propertyKey: string) { console.log(Property ${propertyKey} was decorated); }

@Decorate(LogClass) class A { @Decorate(LogProperty) propertyA = 'A'; }

class B { propertyB = 'B'; }

// The mixed class will inherit the decorators from A const AB = Mixin(A, B); ```

API Reference

For detailed API documentation, please see the API Reference.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and adhere to the code style of the project.

License

This project is licensed under the MIT License - see the LICENSE file for details.