{"version":3,"file":"assignAll.js","sourceRoot":"","sources":["../src/utils/assignAll.ts"],"names":[],"mappings":";;AAAA,wCAA2C;AAC3C,wCAA2C;AAC3C,0CAA6C;AAE7C;;;;;;;;;;GAUG;AACH,mBAAgC,EAAK,EAAE,IAAO,EAAE,QAAuB;IAAvB,yBAAA,EAAA,aAAuB;IACrE,IAAM,UAAU,GAAG,OAAO,gBAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAK,QAAQ,EAAC,CAAC;IAE1E,GAAG,CAAC,CAAe,UAAU,EAAV,yBAAU,EAAV,wBAAU,EAAV,IAAU;QAAxB,IAAM,IAAI,mBAAA;QACb,OAAO,CAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KACzC;IAED,MAAM,CAAC,EAAE,CAAC;AACZ,CAAC;AARD,8BAQC;AAED;;;;;;;;GAQG;AACH,wBAAqC,EAAK,EAAE,IAAO,EAAE,IAAY;IAC/D,IAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAE7D,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3C,IAAM,aAAa,GAAG,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAElE,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QACjD,CAAC;QAAC,IAAI,CAAC,CAAC;YACL,EAAU,CAAC,IAAI,CAAC,GAAI,IAAY,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;AACH,CAAC;AAZD,wCAYC","sourcesContent":["import without = require('lodash/without');\nimport attempt = require('lodash/attempt');\nimport isObject = require('lodash/isObject');\n\n/**\n * Assigns all properties from an object to another object including non enumerable\n * properties.\n * @export\n * @template T\n * @template U\n * @param {T} to\n * @param {U} from\n * @param {string[]} [excludes=[]]\n * @returns {T}\n */\nexport function assignAll(to: T, from: U, excludes: string[] = []): T {\n const properties = without(Object.getOwnPropertyNames(from), ...excludes);\n\n for (const prop of properties) {\n attempt(assignProperty, to, from, prop);\n }\n\n return to;\n}\n\n/**\n * Assigns a property from one object to another while retaining descriptor properties.\n * @export\n * @template T\n * @template U\n * @param {T} to\n * @param {U} from\n * @param {string} prop\n */\nexport function assignProperty(to: T, from: U, prop: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(to, prop);\n\n if (!descriptor || descriptor.configurable) {\n const srcDescriptor = Object.getOwnPropertyDescriptor(from, prop);\n\n if (isObject(srcDescriptor)) {\n Object.defineProperty(to, prop, srcDescriptor);\n } else {\n (to as any)[prop] = (from as any)[prop];\n }\n }\n}\n"]}