functionExtensions.js 670 B

123456789101112131415161718192021222324252627
  1. function extendPrototype(sources, destination) {
  2. var i;
  3. var len = sources.length;
  4. var sourcePrototype;
  5. for (i = 0; i < len; i += 1) {
  6. sourcePrototype = sources[i].prototype;
  7. for (var attr in sourcePrototype) {
  8. if (Object.prototype.hasOwnProperty.call(sourcePrototype, attr)) destination.prototype[attr] = sourcePrototype[attr];
  9. }
  10. }
  11. }
  12. function getDescriptor(object, prop) {
  13. return Object.getOwnPropertyDescriptor(object, prop);
  14. }
  15. function createProxyFunction(prototype) {
  16. function ProxyFunction() {}
  17. ProxyFunction.prototype = prototype;
  18. return ProxyFunction;
  19. }
  20. export {
  21. extendPrototype,
  22. getDescriptor,
  23. createProxyFunction,
  24. };