-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
refactor(loops): Clean up some loops #3362
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,15 +89,14 @@ class EleventyFiles { | |
} | ||
|
||
get passthroughGlobs() { | ||
let paths = new Set(); | ||
// stuff added in addPassthroughCopy() | ||
for (let path of this.passthroughManager.getConfigPathGlobs()) { | ||
paths.add(path); | ||
} | ||
// non-template language extensions | ||
for (let path of this.extensionMap.getPassthroughCopyGlobs(this.inputDir)) { | ||
paths.add(path); | ||
} | ||
let paths = new Set( | ||
// stuff added in addPassthroughCopy() | ||
this.passthroughManager.getConfigPathGlobs() | ||
.concat( | ||
// non-template language extensions | ||
this.extensionMap.getPassthroughCopyGlobs(this.inputDir) | ||
) | ||
); | ||
return Array.from(paths); | ||
} | ||
|
||
|
@@ -184,13 +183,10 @@ class EleventyFiles { | |
} | ||
|
||
getIgnoreGlobs() { | ||
let uniqueIgnores = new Set(); | ||
for (let ignore of this.fileIgnores) { | ||
uniqueIgnores.add(ignore); | ||
} | ||
for (let ignore of this.extraIgnores) { | ||
uniqueIgnores.add(ignore); | ||
} | ||
let uniqueIgnores = new Set( | ||
this.fileIgnores | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this one |
||
.concat(this.extraIgnores), | ||
); | ||
// Placing the config ignores last here is important to the tests | ||
for (let ignore of this.config.ignores) { | ||
uniqueIgnores.add(TemplateGlob.normalizePath(this.localPathRoot || ".", ignore)); | ||
|
@@ -267,11 +263,9 @@ class EleventyFiles { | |
} | ||
|
||
getIgnores() { | ||
let files = new Set(); | ||
|
||
for (let ignore of EleventyFiles.getFileIgnores(this.getIgnoreFiles())) { | ||
files.add(ignore); | ||
} | ||
let files = new Set( | ||
EleventyFiles.getFileIgnores(this.getIgnoreFiles()) | ||
); | ||
|
||
// testing API | ||
if (this.eleventyIgnoreContent !== false) { | ||
|
@@ -431,14 +425,7 @@ class EleventyFiles { | |
if (!filePath) { | ||
return false; | ||
} | ||
|
||
for (let path of paths) { | ||
if (path === filePath) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
return paths.some((path) => path === filePath) | ||
} | ||
|
||
/* For `eleventy --watch` */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,7 +212,7 @@ class Template extends TemplateContent { | |
let results = await Promise.all(promises); | ||
|
||
permalinkValue = {}; | ||
for (let j = 0, k = keys.length; j < k; j++) { | ||
for (let j = 0; j < keys.length; j++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Extracting the length into a variable used to be a performance improvement thing. Is that irrelevant now with newer browser versions? |
||
let key = keys[j]; | ||
permalinkValue[key] = results[j]; | ||
debug( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -653,13 +653,13 @@ class TemplateMap { | |
} | ||
|
||
populateCollectionsWithContent() { | ||
for (let collectionName in this.collectionsData) { | ||
for (let collectionData of Object.values(this.collectionsData)) { | ||
// skip custom collections set in configuration files that have arbitrary types | ||
if (!Array.isArray(this.collectionsData[collectionName])) { | ||
if (!Array.isArray(collectionData)) { | ||
continue; | ||
} | ||
|
||
for (let item of this.collectionsData[collectionName]) { | ||
for (let item of collectionData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Is Line 674 still working as expected? Is there a test for it? |
||
// skip custom collections set in configuration files that have arbitrary types | ||
if (!isPlainObject(item) || !("inputPath" in item)) { | ||
continue; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,13 +96,9 @@ class TemplatePassthroughManager { | |
} | ||
|
||
getNonTemplatePaths(paths) { | ||
let matches = []; | ||
for (let path of paths) { | ||
if (!this.extensionMap.hasEngine(path)) { | ||
matches.push(path); | ||
} | ||
} | ||
|
||
let matches = paths.filter((path) => { | ||
return !this.extensionMap.hasEngine(path); | ||
}); | ||
return matches; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: We might as well return it inline :) |
||
} | ||
|
||
|
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.
Fine with almost all of the style changes here except the .concat ones. I prefer the old method, sorry :-/