leafiy
5/18/2018 - 6:53 PM

es6 object mixin #js #es6 #object

none

function mix(...mixins){
  class Mix{};
  for (let mixin of mixins){
    copyProperties(Mix,mixin);
    copyProperties(Mix.prototype,mixin.prototype);
  }
}
function copyProperties(target,source){
  for (let key of Reflect.ownKeys(source)){
    if(key !== 'constructor' && key !== 'prototype' && key !== 'name'){
      let desc = Object.getOwnPropertyDescriptor(source,key);
      Object.defineProperty(target,key,desc);
    }
  }
}
class DistributedEdit extends mix(){}