Code coverage report for src/util/assign.ts

Statements: 22.22% (4 / 18)      Branches: 8.33% (1 / 12)      Functions: 0% (0 / 2)      Lines: 23.53% (4 / 17)      Ignored: none     

All files » src/util/ » assign.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301   1   1                                                 1
import {root} from './root';
 
const Object = root.Object;
 
Iif (typeof (<any>Object).assign != 'function') {
  (function () {
    (<any>Object).assign = function assignPolyfill(target: Object, ...sources: Array<Object>): 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 = Object.assign;