widgets: use custom obj deepcopy instead of JSON serializing, much faster
This commit is contained in:
parent
debcb99f21
commit
9ad8f3320b
1 changed files with 13 additions and 7 deletions
|
|
@ -1,7 +1,6 @@
|
|||
var osc = require('../../osc')
|
||||
|
||||
|
||||
module.exports = class {
|
||||
module.exports = class _widgets_base {
|
||||
|
||||
static options() {
|
||||
|
||||
|
|
@ -48,17 +47,24 @@ module.exports = class {
|
|||
|
||||
getValue() {
|
||||
|
||||
return _widgets_base.deepCopy(this.value)
|
||||
|
||||
if (typeof this.value == 'object') {
|
||||
}
|
||||
|
||||
return JSON.parse(JSON.stringify(this.value))
|
||||
static deepCopy(obj){
|
||||
|
||||
} else {
|
||||
|
||||
return this.value
|
||||
var copy = obj,
|
||||
key
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
copy = Array.isArray(obj) ? [] : {}
|
||||
for (key in obj) {
|
||||
copy[key] = _widgets_base.deepCopy(obj[key])
|
||||
}
|
||||
}
|
||||
|
||||
return copy
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue