abstract extension system
npm install @teambit/harmonyHarmony takes a "micro-kernel" approach and implements the near-minimum amount of software required to build any JavaScript system from independent components through composition.
bash
$ bit install @teambit/harmony
`Quick start
`ts
import { Harmony, Extension } from 'harmony';@Extensioin
class Person {
sayHello(name = 'world') {
return
hello ${name}!;
}
}const person = Harmony.load(Person);
helloWorld.sayHello(); // returns 'hello world!'
`Component composition
$3
`ts
class Dude {
constructor(
private person: Person
) {} sayHello() {
return this.person.sayHello('dude');
}
};
Harmony.load([Dude]).sayHello(); // echos 'hello dude!'
`$3
`ts
@Extension()
class CLI {
// @hook('command') commands = Hook.create();
static command() {
return Hook.create();
} run() {
const allCommands = this.commands.list(); // outputs all hook subscribers
}
}
@Extension()
class Compiler {
@command()
main() {
return {
synopsis: 'compile ',
render: () =>
};
}
}
``Made with ❤ to open software by Team Bit.