Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Last active August 29, 2015 14:13
Show Gist options
  • Save dealingwith/cb125ff7cc091ea9facb to your computer and use it in GitHub Desktop.
Save dealingwith/cb125ff7cc091ea9facb to your computer and use it in GitHub Desktop.
I think this is ugly, but it's the most readable way I can figure to write this. Suggestions?
setTimeout ->
analytics.track 'Time on Site',
category: 'site',
label: 'seconds',
value: 60
, 60000
@dealingwith
Copy link
Author

BTW, this doesn't count:

delay = (ms, func) -> setTimeout func, ms
delay 60000, ->
  analytics.track 'foo'

@dealingwith
Copy link
Author

BTW, the resulting JS:

setTimeout(function() {
  return analytics.track('Time on Site', {
    category: 'site',
    label: 'seconds',
    value: 60
  });
}, 60000);

To me, that's totally readable. Maybe it's my bias of many years of javascript, but to me punctuation is easier to read than whitespace.

@dealingwith
Copy link
Author

I updated the gist to be the most concise, instead of the most readable, because both are of equal unreadability to me, so I might as well go with concise.

@dealingwith
Copy link
Author

Maybe if I just switch to putting commas at the beginning of lines, the CS wouldn't bother me so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment