# all files / ol/ objectutil.js

96% Statements 24/25
75% Branches 9/12
100% Functions 4/4
96% Lines 24/25

    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    711×

    1×
    1693×

    1693×
    1693×
    1697×
    1697×
    1695×
    2908×
    2908×

    1693×

    1×
    5968×
    36026×

    1×
    804×
    804×
    385×

    804×

    1×
    1316×
    1316×
    356×

    960×

     goog.provide('ol.object');

    /**
     * Polyfill for Object.assign().  Assigns enumerable and own properties from
     * one or more source objects to a target object.
     *
     * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
     * @param {!Object} target The target object.
     * @param {...Object} var_sources The source object(s).
     * @return {!Object} The modified target object.
     */
    ol.object.assign = (typeof Object.assign === 'function') ? Object.assign : function(target, var_sources) {
      Iif (target === undefined || target === null) {
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var output = Object(target);
      for (var i = 1, ii = arguments.length; i < ii; ++i) {
        var source = arguments[i];
        if (source !== undefined && source !== null) {
          for (var key in source) {
            Eif (source.hasOwnProperty(key)) {
              output[key] = source[key];
            }
          }
        }
      }
      return output;
    };

    /**
     * Removes all properties from an object.
     * @param {Object} object The object to clear.
     */
    ol.object.clear = function(object) {
      for (var property in object) {
        delete object[property];
      }
    };

    /**
     * Get an array of property values from an object.
     * @param {Object<K,V>} object The object from which to get the values.
     * @return {!Array<V>} The property values.
     * @template K,V
     */
    ol.object.getValues = function(object) {
      var values = [];
      for (var property in object) {
        values.push(object[property]);
      }
      return values;
    };

    /**
     * Determine if an object has any properties.
     * @param {Object} object The object to check.
     * @return {boolean} The object is empty.
     */
    ol.object.isEmpty = function(object) {
      var property;
      for (property in object) {
        return false;
      }
      return !property;
    };