123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
-
-
- 'use strict';
-
-
-
- module.exports = function copyDescriptor(receiver, provider, from, to) {
- if (!isObject(provider) && typeof provider !== 'function') {
- to = from;
- from = provider;
- provider = receiver;
- }
- if (!isObject(receiver) && typeof receiver !== 'function') {
- throw new TypeError('expected the first argument to be an object');
- }
- if (!isObject(provider) && typeof provider !== 'function') {
- throw new TypeError('expected provider to be an object');
- }
-
- if (typeof to !== 'string') {
- to = from;
- }
- if (typeof from !== 'string') {
- throw new TypeError('expected key to be a string');
- }
-
- if (!(from in provider)) {
- throw new Error('property "' + from + '" does not exist');
- }
-
- var val = Object.getOwnPropertyDescriptor(provider, from);
- if (val) Object.defineProperty(receiver, to, val);
- };
-
- function isObject(val) {
- return {}.toString.call(val) === '[object Object]';
- }
|