mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 16:43:36 -05:00
Make variadic options more explicit
This commit is contained in:
parent
790b9ea8ed
commit
3966e2f85b
1 changed files with 12 additions and 7 deletions
|
@ -85,17 +85,22 @@ module.exports = Router =
|
||||||
# doc_id, options, callback
|
# doc_id, options, callback
|
||||||
# doc_id, fromVersion, options, callback
|
# doc_id, fromVersion, options, callback
|
||||||
client.on "joinDoc", (doc_id, fromVersion, options, callback) ->
|
client.on "joinDoc", (doc_id, fromVersion, options, callback) ->
|
||||||
if typeof fromVersion == "function"
|
if typeof fromVersion == "function" and !options
|
||||||
fromVersion = -1
|
|
||||||
options = {}
|
|
||||||
callback = fromVersion
|
callback = fromVersion
|
||||||
else if typeof fromVersion == "object"
|
|
||||||
fromVersion = -1
|
fromVersion = -1
|
||||||
options = fromVersion
|
|
||||||
callback = options
|
|
||||||
if typeof options == "function"
|
|
||||||
options = {}
|
options = {}
|
||||||
|
else if typeof fromVersion == "number" and typeof options == "function"
|
||||||
callback = options
|
callback = options
|
||||||
|
options = {}
|
||||||
|
else if typeof fromVersion == "object" and typeof options == "function"
|
||||||
|
callback = options
|
||||||
|
options = fromVersion
|
||||||
|
fromVersion = -1
|
||||||
|
else if typeof fromVersion == "number" and typeof options == "object"
|
||||||
|
# Called with 4 args, things are as expected
|
||||||
|
else
|
||||||
|
logger.error { arguments: arguments }, "unexpected arguments"
|
||||||
|
return {} # ????
|
||||||
|
|
||||||
WebsocketController.joinDoc client, doc_id, options, fromVersion, (err, args...) ->
|
WebsocketController.joinDoc client, doc_id, options, fromVersion, (err, args...) ->
|
||||||
if err?
|
if err?
|
||||||
|
|
Loading…
Reference in a new issue