Mixin library with full typescript/intellisense support for the Simtopy project
  • JavaScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2023-10-26 13:11:11 +00:00
.gitignore removed declaration file from repo 2022-09-02 09:30:25 +00:00
.gitlab-ci.yml Update .gitlab-ci.yml 2023-10-26 13:11:11 +00:00
index.js export UnknownClass 2022-09-12 08:33:33 +00:00
jsconfig.json jsconfig.json 2022-09-02 09:31:48 +00:00
mix.js fix unability to extends a class 2022-09-07 14:11:58 +00:00
package-lock.json ts is a dev dep only 2022-09-08 10:20:46 +00:00
package.json export UnknownClass 2022-09-12 08:33:33 +00:00
README.md updated readme to add classes names 2022-09-06 06:51:41 +00:00
test.js fix unability to extends a class 2022-09-07 14:11:58 +00:00
tsconfig.json up 2022-09-02 09:22:46 +00:00

mix

Typed mixin framework for Simtopy libs.

Based on https://github.com/justinfagnani/mixwith.js

Usage

import mix, { Mixin } from "@simtopy/mix"

Declare mixins components

const aMixin = Mixin((superclass) => class A extends superclass {
  constructor(key, ...args) {
    super(key, ...args)
  }
  get a() {
    return "a"
  }
})

const bMixin = Mixin((superclass) => class B extends superclass {
  constructor(key, ...args) {
    super(key, ...args)
  }
  get b() {
    return "b"
  }
})

const cMixin = Mixin((superclass) => class C extends superclass {
  constructor(key, ...args) {
    super(key, ...args)
  }
  get c() {
    return "c"
  }
})

Declare mixin class

class Toto extends mix(aMixin).and(bMixin).and(cMixin).returns() {}

Enjoy !

Instance of toto have all methods and attributes of the mixins, besides, they are recognized and correctly typed by intellisense.

Instanceof operator works has well.