CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
defaults.js65 linesDownload Raw Back to lodash-es
1import baseRest from './_baseRest.js';2import eq from './eq.js';3import isIterateeCall from './_isIterateeCall.js';4import keysIn from './keysIn.js';5 6/** Used for built-in method references. */7var objectProto = Object.prototype;8 9/** Used to check objects for own properties. */10var hasOwnProperty = objectProto.hasOwnProperty;11 12/**13 * Assigns own and inherited enumerable string keyed properties of source14 * objects to the destination object for all destination properties that15 * resolve to `undefined`. Source objects are applied from left to right.16 * Once a property is set, additional values of the same property are ignored.17 *18 * **Note:** This method mutates `object`.19 *20 * @static21 * @since 0.1.022 * @memberOf _23 * @category Object24 * @param {Object} object The destination object.25 * @param {...Object} [sources] The source objects.26 * @returns {Object} Returns `object`.27 * @see _.defaultsDeep28 * @example29 *30 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });31 * // => { 'a': 1, 'b': 2 }32 */33var defaults = baseRest(function(object, sources) {34  object = Object(object);35 36  var index = -1;37  var length = sources.length;38  var guard = length > 2 ? sources[2] : undefined;39 40  if (guard && isIterateeCall(sources[0], sources[1], guard)) {41    length = 1;42  }43 44  while (++index < length) {45    var source = sources[index];46    var props = keysIn(source);47    var propsIndex = -1;48    var propsLength = props.length;49 50    while (++propsIndex < propsLength) {51      var key = props[propsIndex];52      var value = object[key];53 54      if (value === undefined ||55          (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {56        object[key] = source[key];57      }58    }59  }60 61  return object;62});63 64export default defaults;65 
basant307/AI_Governance_Project · CoolFace