CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
assign.js59 linesDownload Raw Back to lodash-es
1import assignValue from './_assignValue.js';2import copyObject from './_copyObject.js';3import createAssigner from './_createAssigner.js';4import isArrayLike from './isArrayLike.js';5import isPrototype from './_isPrototype.js';6import keys from './keys.js';7 8/** Used for built-in method references. */9var objectProto = Object.prototype;10 11/** Used to check objects for own properties. */12var hasOwnProperty = objectProto.hasOwnProperty;13 14/**15 * Assigns own enumerable string keyed properties of source objects to the16 * destination object. Source objects are applied from left to right.17 * Subsequent sources overwrite property assignments of previous sources.18 *19 * **Note:** This method mutates `object` and is loosely based on20 * [`Object.assign`](https://mdn.io/Object/assign).21 *22 * @static23 * @memberOf _24 * @since 0.10.025 * @category Object26 * @param {Object} object The destination object.27 * @param {...Object} [sources] The source objects.28 * @returns {Object} Returns `object`.29 * @see _.assignIn30 * @example31 *32 * function Foo() {33 *   this.a = 1;34 * }35 *36 * function Bar() {37 *   this.c = 3;38 * }39 *40 * Foo.prototype.b = 2;41 * Bar.prototype.d = 4;42 *43 * _.assign({ 'a': 0 }, new Foo, new Bar);44 * // => { 'a': 1, 'c': 3 }45 */46var assign = createAssigner(function(object, source) {47  if (isPrototype(source) || isArrayLike(source)) {48    copyObject(source, keys(source), object);49    return;50  }51  for (var key in source) {52    if (hasOwnProperty.call(source, key)) {53      assignValue(object, key, source[key]);54    }55  }56});57 58export default assign;59 
basant307/AI_Governance_Project · CoolFace