-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🏗 SwG Release 0.1.22.152 #33329
🏗 SwG Release 0.1.22.152 #33329
Conversation
This reverts commit 7e9c9ce.
Lucky commits for St. Patty's Day release
Hey @rileyajones ! We updated the |
@@ -955,7 +875,7 @@ class JsonLdParser { | |||
possibleConfigs = [possibleConfigs]; | |||
} | |||
|
|||
for (let i = 0; i < possibleConfigs.length; i++) { | |||
for (let i = 0; i < /** @type {Array} */ (possibleConfigs).length; i++) { |
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.
nitpicks (feel free to ignore):
- What is this an array of
/** @type {Array<some type?>}*/
? - Making this a for in loop would remove the assignment required on like 879 and prevent
i
being overloaded be the inner loop on line 890.
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.
I'll follow up in another PR!
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.
-
Page config parser: Improves typing subscriptions-project/swg-js#1564 updates the type to
!Array{!JsonObject}
-
Would a for-in loop remove the assignment? I know a for-of loop would, but currently we can only use those in tests and build-system stuff
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.
Forgot about that, I pretty much just work in build-system. A forEach
loop would also work.
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.
find()
might be better, since we want to terminate the loop after finding a match
forEach()
loops only terminate on exceptions
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.
TBH I hadn't really tried to understand what the code was doing. A find would be great. Maybe something like this?
const {config, productId} = possibleConfigs
.filter(config => this.checkType_.checkValue(config['@type'], ALLOWED_TYPES))
.map(config => {
const partOfArray = this.valueArray_(config, 'isPartOf');
if (!partOfArray) {
return;
}
for (let i = 0; i < partOfArray.length; i++) {
productId = this.discoverProductId_(partOfArray[i]);
if (productId) {
return {config, productId};
}
}
})
.find(Boolean) || {};
const isAccessibleForFree = this.bool_(
this.singleValue_(config, 'isAccessibleForFree'),
/* default */ true
);
return new PageConfig(productId, !isAccessibleForFree);
Version: 0.1.22.152
Previous release: 0.1.22.151
=
padding characters when encoding, and leaves them when decoding (add dateModified and description to article metadata examples #1543)postMessage
from an intended source #1539)