2011-08-14 21:35:36 +00:00
|
|
|
(function(){
|
2013-02-26 23:48:27 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
/**
|
|
|
|
|
* Copies all enumerable properties of one object to another
|
|
|
|
|
* @memberOf fabric.util.object
|
|
|
|
|
* @method extend
|
|
|
|
|
* @param {Object} destination Where to copy to
|
|
|
|
|
* @param {Object} source Where to copy from
|
|
|
|
|
*/
|
|
|
|
|
function extend(destination, source) {
|
|
|
|
|
// JScript DontEnum bug is not taken care of
|
|
|
|
|
for (var property in source) {
|
|
|
|
|
destination[property] = source[property];
|
|
|
|
|
}
|
|
|
|
|
return destination;
|
2010-06-17 14:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
/**
|
|
|
|
|
* Creates an empty object and copies all enumerable properties of another object to it
|
|
|
|
|
* @method clone
|
|
|
|
|
* @memberOf fabric.util.object
|
|
|
|
|
* @param {Object} object Object to clone
|
|
|
|
|
*/
|
|
|
|
|
function clone(object) {
|
|
|
|
|
return extend({ }, object);
|
|
|
|
|
}
|
2010-06-17 14:00:47 +00:00
|
|
|
|
2013-02-26 23:48:27 +00:00
|
|
|
/** @namespace Object utilities */
|
2011-08-14 21:35:36 +00:00
|
|
|
fabric.util.object = {
|
|
|
|
|
extend: extend,
|
|
|
|
|
clone: clone
|
|
|
|
|
};
|
2013-02-26 23:48:27 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
})();
|