Every line of '_ extend' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
620 function extend() { 621 if (arguments.length < 2) { 622 throw new Error('There must be at least 2 arguments.'); 623 } 624 625 var target = arguments[0]; 626 for (var i = 1; i < arguments.length; i++) { 627 var source = arguments[i]; 628 for (var prop in source) { 629 if (source.hasOwnProperty(prop)) { 630 target[prop] = source[prop]; 631 } 632 } 633 } 634 return target; 635 }
27 function extend(options) { 28 var rmxExtendLogger = utils.logger('Rmx.extend'); 29 var name = options.name; 30 var core = options.core; 31 32 var returnValue = void 0; 33 var rmxutilities = void 0; 34 35 if (utils.fullTypeOf(name) === 'String') { 36 if (utils.fullTypeOf(core) === 'Function') { 37 this.prototype[name] = function () { 38 this.selector = utils.clear(this.selector); 39 rmxutilities = require('./rmxutilities')(this, { 40 arguments: arguments 41 }); 42 core.call(this, rmxutilities); 43 return name[0] === name[0].toUpperCase() ? rmxutilities.return : this; 44 }; 45 } else { 46 rmxExtendLogger.error('core - ' + utils.fullTypeOf(name) + ' instead of Function'); 47 } 48 } else { 49 rmxExtendLogger.error('name - ' + utils.fullTypeOf(name) + ' instead of String'); 50 } 51 }
27 _extend (options: UrlOptions): UrlOptions { 28 return super._extend(options) as UrlOptions 29 }
674 function extend( _, __ ) 675 { 676 var args = [], 677 i = arguments.length; 678 679 // passing arguments object prohibits optimizations in v8 680 while ( i-- ) args[ i ] = arguments[ i ]; 681 682 // set up the new class 683 var new_class = class_builder.build.apply( class_builder, args ); 684 685 // set up some additional convenience props 686 setupProps( new_class ); 687 688 // lock down the new class (if supported) to ensure that we can't add 689 // members at runtime 690 util.freeze( new_class ); 691 692 return new_class; 693 }
3 function extend() { //extend 深拷贝实现 4 var name, options, src, copy, 5 deep = false, //是否深拷贝 默认为false 6 length = arguments.length, 7 i = 1, 8 target = arguments[0] || {}; 9 //如果第一个参数为boolean类型,赋值给deep 10 if (typeof target == 'boolean') { 11 deep = arguments[0]; 12 target = arguments[i] || {}; //目标对象顺延 13 i++; 14 } 15 //如果target不是对象数据类型的话 target赋值为 {} 16 if (['object', 'function'].indexOf(typeof target) < 0) { 17 target = {}; 18 } 19 for (; i < length; i++) { 20 options = arguments[i]; 21 if (options != null) { 22 for (name in options) { 23 copy = options[name]; 24 src = target[name]; 25 if (target === copy) { //避免重复循环 26 continue; 27 } 28 if (deep && copy && (typeof copy == 'object')) { // 类型判断 29 src = Object.prototype.toString.call(copy) == '[object Array]' ? [] : {}; //区分数组和‘对象' 30 target[name] = extend(deep, src, copy); 31 } else { 32 if (copy !== undefined) { 33 target[name] = copy; 34 } 35 } 36 } 37 } 38 } 39 return target 40 }
15 export function extend(obj, ...args) { 16 args.forEach(a => { 17 if (typeof a === 'object') { 18 Object.keys(a).forEach(key => obj[key] = a[key]); 19 } 20 }); 21 return obj; 22 }
241 function extend(obj) { 242 Array.prototype.slice.call(arguments, 1).forEach(function (source) { 243 if (!source) { return; } 244 245 Object.keys(source).forEach(function (name) { 246 obj[name] = source[name]; 247 }); 248 }); 249 250 return obj; 251 }
423 function _extend(origin, add) { 424 // Don't do anything if add isn't an object 425 if (!add || !isObject(add)) return origin; 426 427 var keys = objectKeys(add); 428 var i = keys.length; 429 while (i--) { 430 origin[keys[i]] = add[keys[i]]; 431 } 432 return origin; 433 }
40 function extend(stu){ 41 stu = stu || object.clone(stuff); 42 var cpstu = object.clone(stu); 43 //console.log(deps); 44 //console.log(stu); 45 var len = stu.length 46 , is = 0; 47 for(var s in stu){ 48 var yl = deps[stu[s]]; 49 //console.log(stu[s]+' yl '+yl); 50 if(yl){ 51 for (var y in yl) cpstu.splice(is, 0, yl[y]); 52 is += yl.length; 53 } 54 is++; 55 } 56 cpstu = array.unique(cpstu); //去重 57 if(cpstu.length>len){ //下一层递归 58 return extend(cpstu); 59 } 60 return cpstu; 61 }
40 extend(options) { 41 if (options) { 42 $.extend(this, options) 43 } 44 return this; 45 }