How would the core feel about a safe version of Object.extend? Object.extend = function(destination, source, safe) { safe = !!safe || false; for (var property in source){ destination[property] = (safe && typeof destination[property] !== 'undefined') ? destination[property] : source[property]; } return destination; };
Existing functionality is covered (safe defaults false, which goes to source[property], no need to change anything. i found a recent need to extend a class object after it had been created, but i didn't want to overwrite properties if they'd already been defined. i imagine there would be some minimal performance hit testing each property if safe==true, but otherwise...? Any visible problems? Just a suggestion, it helped me out. -joe t. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---