diff --git a/src/util/assign.ts b/src/util/assign.ts new file mode 100644 index 0000000000..f1ebd6c0f9 --- /dev/null +++ b/src/util/assign.ts @@ -0,0 +1,30 @@ +import {root} from './root'; + +const Object = root.Object; + +if (typeof (Object).assign != 'function') { + (function () { + (Object).assign = function assignPolyfill(target: Object, ...sources: Array): Object { + if (target === undefined || target === null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + + const output = Object(target); + const len = sources.length; + for (let index = 0; index < len; index++) { + let source = sources[index]; + if (source !== undefined && source !== null) { + for (let key in source) { + if (source.hasOwnProperty(key)) { + output[key] = source[key]; + } + } + } + } + + return output; + }; + })(); +} + +export const assign: (target: Object, ...sources: Array) => Object = Object.assign; \ No newline at end of file