Last active
December 12, 2016 10:12
-
-
Save zerobias/01eae0e49e5542ed85cb8074423fe757 to your computer and use it in GitHub Desktop.
Native dynamic es6 class mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Storage = Sup => class extends Sup { | |
save(database) { } | |
} | |
const Validation = Sup => class extends Sup { | |
validate(schema) { } | |
} | |
class Person { } | |
class Employee extends Storage(Validation(Person)) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tap = require('tap').test | |
const Execution = Sup => class extends Sup { get run() { return true } } | |
class TestObject { get isTestObject() { return true } } | |
tap('execution mixin test', | |
function(t){ | |
class ExtendedObject extends Execution( TestObject ) { } | |
const tested = new ExtendedObject() | |
t.ok(tested) | |
t.ok(tested.isTestObject) | |
t.ok(tested.run) | |
t.end() | |
} | |
) | |
/* | |
# Subtest: execution mixin test | |
ok 1 - expect truthy value | |
ok 2 - expect truthy value | |
ok 3 - expect truthy value | |
1..3 | |
ok 1 - execution mixin test | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment