mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
refactor(util) copyObj
This commit is contained in:
parent
86cbe86f60
commit
749c861f86
1 changed files with 7 additions and 14 deletions
21
lib/util.js
21
lib/util.js
|
|
@ -203,22 +203,15 @@
|
|||
* @param pToObj
|
||||
* @param pProps
|
||||
*/
|
||||
this.copyObj = function(pFromObj, pToObj, pProps) {
|
||||
var toObj = pToObj || pProps || {},
|
||||
forIn = function(obj) {
|
||||
Util.forIn(obj, function(name) {
|
||||
toObj[name] = obj[name];
|
||||
});
|
||||
};
|
||||
this.copyObj = function(from, to) {
|
||||
if (!to)
|
||||
to = {};
|
||||
|
||||
if (Util.isObject(pFromObj)) {
|
||||
if (pProps)
|
||||
forIn(pProps);
|
||||
|
||||
forIn(pFromObj);
|
||||
}
|
||||
Util.forIn(from, function(name) {
|
||||
to[name] = from[name];
|
||||
});
|
||||
|
||||
return toObj;
|
||||
return to;
|
||||
};
|
||||
|
||||
this.convertArrToObj = function(pArrKeys, pArrVal) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue