mirror of
https://github.com/nuintun/command-manager.git
synced 2025-10-20 01:27:47 +08:00
update files
This commit is contained in:
37
static/js/util/index.js
Normal file
37
static/js/util/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Created by nuintun on 2015/11/23.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
normalize: function (vue){
|
||||
return JSON.parse(JSON.stringify(vue));
|
||||
},
|
||||
clone: function (object){
|
||||
var result;
|
||||
|
||||
switch (typeof object) {
|
||||
case 'object':
|
||||
if (object === null) {
|
||||
result = null;
|
||||
} else {
|
||||
if (Array.isArray(object)) {
|
||||
result = object.slice(0);
|
||||
} else {
|
||||
result = {};
|
||||
|
||||
Object.keys(object).forEach(function (key){
|
||||
result[key] = module.exports.clone(object[key]);
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = object;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user