-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Just think that ES6 is not trying to use Reflect?
Modified the code
var aggregation = (base, ...mixins) => {
/* create aggregation class */
let aggregate = class __Aggregate extends base {
constructor (...args) {
/* call base class constructor */
super(...args)
/* call mixin's initializer */
mixins.forEach(mixin => {
if (typeof mixin.prototype.initializer === 'function') { mixin.prototype.initializer.apply(this, args) }
})
}
}
/* copy properties */
let copyProps = (target, source) => {
Reflect.ownKeys(source)
.forEach(prop => {
if (
prop.match(
/^(?:initializer|constructor|prototype|arguments|caller|name|bind|call|apply|toString|length)$/
)
) { return }
Reflect.set(
target,
prop,
Reflect.getOwnPropertyDescriptor(source, prop)
)
})
}
/* copy all properties of all mixins into aggregation class */
mixins.forEach(mixin => {
copyProps(aggregate.prototype, mixin.prototype)
copyProps(aggregate, mixin)
})
return aggregate
}Finally, I feel that Reflect is a bit more interesting, nothing more. o((^▽^))o
Metadata
Metadata
Assignees
Labels
No labels