Mixin.ts
A typescript library which allows a class to extend multiple classes.
Import
import { mixin } from "mixin.ts"
Usage
classes can be written as TypeScript classes or just functions
// functionCar.prototype.drive =Car.prototype.model = "Toyota"; // TypeScript class // Truck contains methods and properites from both Car and lorry; Truck.drive"truck"; // This truck can drive very fastTruck.carry10; // This vehicle can carry 10 kg console.logTruck.model // Toyota
By default, mixin
returns an instance of the created class. To return the created class or function itself, pass true
as the second argument to mixin
.
;;truck.drive"new truck"; // This new truck can drive very fasttruck.carry100; // This vehicle can carry 100 kg
Install Choices
npm install mixin.ts
- download the zip
- clone the repo
License
(The MIT License)