Merge branch 'master' into v1

This commit is contained in:
bordun 2020-02-23 16:36:10 +01:00
commit 3ad7915b8f
103 changed files with 94 additions and 59 deletions

39
src/client/utils.js Normal file
View file

@ -0,0 +1,39 @@
module.exports = {
deepCopy: function(obj, precision) {
var copy = obj
if (obj === null) {
return obj
}
if (typeof obj === 'object') {
copy = Array.isArray(obj) ? [] : {}
for (let key in obj) {
copy[key] = module.exports.deepCopy(obj[key], precision)
}
} else if (typeof obj == 'number') {
return precision === undefined ? copy : parseFloat(copy.toFixed(precision))
}
return copy
},
deepEqual: function(a, b) {
var ta = typeof a,
tb = typeof b
if (ta !== tb) {
return false
} else if (ta === 'object') {
return JSON.stringify(a) === JSON.stringify(b)
} else {
return a === b
}
}
}