workerize icon indicating copy to clipboard operation
workerize copied to clipboard

refactor: flatten nested if-else blocks

Open cades opened this issue 7 years ago • 3 comments

apply "return early, avoid else" practice to make code simple and easy to read

cades avatar Jan 10 '18 18:01 cades

Need to check the effect on filesize, but I'd imagine this is a savings! (due to uglify better optimizing early returns than nested conditionals)

developit avatar Jan 10 '18 19:01 developit

hey @cades - that nested .then() is important - without it, an exception thrown by the method being called won't be passed back via RPC, it'll just be emitted as an error in the worker.

developit avatar Jan 12 '18 01:01 developit

@developit thanks for point that out! Seems my knowledge to Promise is not promising 😂 BTW, if you think it is OK to accept this PR, I'm willing to squash these commits into a single commit before merge.

cades avatar Jan 12 '18 02:01 cades