utils.js 562 B

1234567891011121314151617181920
  1. "use strict";
  2. module.exports.mixin = function mixin(target, source) {
  3. const keys = Object.getOwnPropertyNames(source);
  4. for (let i = 0; i < keys.length; ++i) {
  5. Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
  6. }
  7. };
  8. module.exports.wrapperSymbol = Symbol("wrapper");
  9. module.exports.implSymbol = Symbol("impl");
  10. module.exports.wrapperForImpl = function (impl) {
  11. return impl[module.exports.wrapperSymbol];
  12. };
  13. module.exports.implForWrapper = function (wrapper) {
  14. return wrapper[module.exports.implSymbol];
  15. };