Socket
Socket
Sign inDemoInstall

@preterer/mixin

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @preterer/mixin

Typescript extendable mixin approach


Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Install size
16.1 kB
Created
Weekly downloads
 

Readme

Source

mixin

Extendable typescript mixin approach. Currently supports up to 6 mixed classes.

Usage

class A {
    public a: string = "a";

    public getA(): string {
        return this.a;
    }

    public overwritten(): string {
        return "a";
    }
}

class B {
    public b: string = "b";

    public getB(): string {
        return this.b;
    }

    public overwritten(): string {
        return "b":
    }
}

class C extends mixin(A, B) {
    public c: string = "c";

    public getC(): string {
        return this.c;
    }

    public overwritten(): string {
        return "c";
    }
}

const c = new C();

c.a; // "a"
c.b; // "b"
c.c; // "c"
c.getA(); // "a"
c.getB(); // "b"
c.getC(); // "c"
c.overwritten(); // "c"

const MixedClass = mixin(A, B);
const mixed = new MixedClass();

mixed.a; // "a"
mixed.b; // "b"
mixed.getA(); // "a"
mixed.getB(); // "b"
mixed.overwritten(); // "b"

Project setup

npm install

Tests

npm run test

Build

npm run build

Keywords

FAQs

Last updated on 11 Feb 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc