widgets: use custom obj deepcopy instead of JSON serializing, much faster

This commit is contained in:
jean-emmanuel 2017-01-04 22:12:47 +01:00
parent debcb99f21
commit 9ad8f3320b

View file

@ -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
}
}