github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/js/object-assign.js (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
    12  
    13  if (typeof Object.assign != 'function') {
    14    (function () {
    15      Object.assign = function (target) {
    16        'use strict';
    17        if (target === undefined || target === null) {
    18          throw new TypeError('Cannot convert undefined or null to object');
    19        }
    20  
    21        var output = Object(target);
    22        for (var index = 1; index < arguments.length; index++) {
    23          var source = arguments[index];
    24          if (source !== undefined && source !== null) {
    25            for (var nextKey in source) {
    26              if (source.hasOwnProperty(nextKey)) {
    27                output[nextKey] = source[nextKey];
    28              }
    29            }
    30          }
    31        }
    32        return output;
    33      };
    34    })();
    35  }