/**
 * Copy a object deeply.
 * @function lib.object.deepCopy
 * @param {object} src - Object to copy from.
 * @param {object} dest - Object to copy to.
 * @returns {object} - Copied object.
 * @author Taka Okunishi
 *
 */
exports = module.exports = function (src, dest) {
    switch (typeof(dest)) {
        case'string':
        case'number':
            dest = {};
            break;
        default:
            break;
    }
    for (var key in src) {
        if (!src.hasOwnProperty(key)) continue;
        var value = src[key];
        if (value instanceof Date) {
            dest[key] = new Date(value);
        } else if (value instanceof Function) {
            dest[key] = value;
        } else if (value instanceof Array) {
            dest[key] = [].concat(value);
        } else if (value instanceof Object) {
            dest[key] = exports(value, dest[key] || {});
        } else {
            dest[key] = value;
        }
    }
    return dest;
};
