Clean up old unused code
This commit is contained in:
1 parent
4b5dc25010
commit
771917a7a6
5 files changed
+4
-50
No files matched your search
@@ -56,21 +56,6 @@ typeOf = (obj) ->
|
||||
Object.prototype.toString.call(obj)
|
||||
|
||||
|
||||
exports.endsWith = (str, suffix) ->
|
||||
str.indexOf(suffix, str.length - suffix.length) isnt -1
|
||||
|
||||
|
||||
exports.startsWith = (str, prefix) ->
|
||||
str.substring(0, prefix.length) == prefix
|
||||
|
||||
|
||||
exports.arrayToHash = (arr) ->
|
||||
hash = {}
|
||||
for i in arr
|
||||
hash[i[0]] = i[1]
|
||||
return hash
|
||||
|
||||
|
||||
exports.generateDeviceId = (deviceIdStruct) ->
|
||||
# Percent escaping function. Escapes everything except alphanumerics and underscore
|
||||
esc = (str) ->
|
||||
@@ -88,34 +73,6 @@ exports.generateDeviceId = (deviceIdStruct) ->
|
||||
return "#{esc(deviceIdStruct['OUI'])}-#{esc(deviceIdStruct['SerialNumber'])}"
|
||||
|
||||
|
||||
exports.parseDeviceId = (deviceId) ->
|
||||
parts = deviceId.split('-')
|
||||
ret = {oui : querystring.unescape(parts[0])}
|
||||
if parts.length == 3
|
||||
ret.productClass = querystring.unescape(parts[1])
|
||||
ret.serialNumber = querystring.unescape(parts[2])
|
||||
else
|
||||
ret.serialNumber = querystring.unescape(parts[1])
|
||||
return ret
|
||||
|
||||
|
||||
exports.extend = (obj, mixin) ->
|
||||
obj[name] = method for name, method of mixin
|
||||
obj
|
||||
|
||||
|
||||
exports.flattenObject = (object) ->
|
||||
newObj = {}
|
||||
f = (obj, prefix) ->
|
||||
for k, v of obj
|
||||
if typeof(v) is 'object'
|
||||
f(v, "#{prefix}#{k}.")
|
||||
else
|
||||
newObj["#{prefix}#{k}"] = v
|
||||
f(object, '')
|
||||
return newObj
|
||||
|
||||
|
||||
exports.getParamValueFromPath = (obj, path) ->
|
||||
pp = path.split('.')
|
||||
ref = obj
|
||||
|
||||
+1
-4
@@ -62,7 +62,6 @@ options = {
|
||||
XML_IGNORE_NAMESPACE : {type : 'bool', default : false},
|
||||
|
||||
# Should probably never be changed
|
||||
PRESETS_TIME_PADDING : {type : 'int', default : 1},
|
||||
DEVICE_ONLINE_THRESHOLD : {type : 'int', default : 4000}
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ setConfig = (name, value, commandLineArgument) ->
|
||||
if name == n
|
||||
_value = cast(value, optionDetails.type)
|
||||
n = optionName
|
||||
else if common.startsWith(name, "#{n}-")
|
||||
else if name.startsWith("#{n}-")
|
||||
_value = cast(value, optionDetails.type)
|
||||
n = "#{optionName}-#{name[optionName.length+1..]}"
|
||||
|
||||
@@ -163,5 +162,3 @@ try
|
||||
exports.auth = require(path.resolve(allConfig.CONFIG_DIR, 'auth'))
|
||||
|
||||
exports.get = get
|
||||
|
||||
exports.allConfig = allConfig
|
||||
+1
-1
@@ -126,7 +126,7 @@ optimizeProjection = (obj) ->
|
||||
while i < keys.length
|
||||
a = keys[i-1]
|
||||
b = keys[i]
|
||||
if common.startsWith(b, a)
|
||||
if b.startsWith(a)
|
||||
if b.charAt(a.length) == '.' or b.charAt(a.length - 1) == '.'
|
||||
delete obj[b]
|
||||
keys.splice(i--, 1)
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ expand = (query) ->
|
||||
else
|
||||
new_query['$and'].push({'$or' : conditions})
|
||||
else
|
||||
common.extend(new_query, conditions[0])
|
||||
Object.assign(new_query, conditions[0])
|
||||
|
||||
return new_query
|
||||
|
||||
|
||||
+1
-1
@@ -1356,7 +1356,7 @@ rpcResponse = (sessionData, id, rpcRes, callback) ->
|
||||
while (i = p[0].lastIndexOf('.', i - 1)) > rpcReq.parameterPath.length
|
||||
missing[p[0].slice(0, i)] |= 0
|
||||
|
||||
if common.endsWith(p[0], '.')
|
||||
if p[0].endsWith('.')
|
||||
missing[p[0][0...-1]] |= 1
|
||||
path = common.parsePath(p[0][0...-1])
|
||||
if not rpcReq.nextLevel
|
||||
|
||||
Reference in new issue
Block a user