LiveScript icon indicating copy to clipboard operation
LiveScript copied to clipboard

long long if's (how-to go about it)

Open determin1st opened this issue 5 years ago • 4 comments

For example, if you have some if:

if (typeof options.data == 'string') or (typeof! options.data == 'URLSearchParams')
  true

It's rather long and with more indenting inside some function function with tabs/spaces... readability (of this line) should be broken, eventually..

On the other hand, having this javascript code:

if (typeof options.data === 'string' ||
    toString$.call(options.data).slice(8, -1) === 'URLSearchParams')
{
  true;
}

looks better, right?

So, the question is how to go about long if's, how to indent them, space them, multiline them (in livescript ofc) or this is not possible/resonable/smart enough etc?

determin1st avatar Jan 16 '20 17:01 determin1st

How about:

if (true or
    false) and
    false
    #----
    console.log "foo"
else
    console.log "bar"

ceremcem avatar Jan 16 '20 19:01 ceremcem

if typeof! options.data in <[String URLSearchParams]>

vendethiel avatar Jan 16 '20 22:01 vendethiel

Great, will use both!

determin1st avatar Jan 17 '20 04:01 determin1st

You can use a backslash to ignore a newline:

if something? \
  or something-else?
  do-something!

anko avatar Jan 18 '20 17:01 anko