-
-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small simplifications #3243
Small simplifications #3243
Conversation
1af79d9
to
8f23e8f
Compare
Updated based on your feedback. Whatcha think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #3243 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. I dunno what I was mis-remembering…maybe it was from when I used to work in Python? 🤷♂️
I’ll fix it shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c69fe27.
Some tweaks to (hopefully) make some loops a little faster to grok
A little use of the newer optional chaning operator to make some repetetive conditionals slightly faster to read.
Some targeted use of `.some()` and `.includes()` to convey the intention in compact fashion.
Some rewrites involving `Set`s, often involved in making it easier to grok what’s populating the set at a glance.
The standard functional tools for manipulating Arrays (usually `.map()` and `.filter()`) make it easy to write some code that reads a little bit like a pipeline. Some small rewrites can make these even easier to read. If the arrow function is short enough, using the single-line syntax can make it less noisy by avoiding the need for braces `{`|`}` or `return`. Using the static methods _directly_ for the callback is even better, since it’s not even necessary to use an anonymous arrow function or name any arguments.
bf63527
to
00c5180
Compare
I messed up on a rebase. 🤦♂️ I’ll redo this in a new PR. |
These are an assortment of small tweaks.
My goal was to make these bits of code easier to understand at a glance. There’s plenty of subjectivity in that, to be sure.
Some of these make use of Javascript features that were not available a few years ago. (Both syntax and APIs of built-in objects.) Hopefully, I applied them in a way that makes it easier to understand each block of code. Since Eleventy v3 is still in alpha, I thought this would be a good time to introduce them, since they are supported pretty much everywhere and a major version increment doesn’t have to worry about breaking compatibility.