-
Notifications
You must be signed in to change notification settings - Fork 213
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
replaced classes with objects #327
Conversation
Also please make sure all the documentation .md files are updated |
Please note that function myObject() {....} is still a 'class' you can just do a new myObject(). |
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.
This 3 line will break vast-client.
if (this.creative instanceof createCreativeLinear) {
if (this.variation instanceof createNonLinearAd) {
if (this.variation instanceof createCompanionAd) {
will need to implement isCreativeLinear
, isCreativeNonLinear
and isCreativeCompanionAd
,
src/ad_extension.js
Outdated
this.children.length === 0 | ||
); | ||
} | ||
export function isEmpty(adExtension) { |
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.
WDYT ?
export function isEmpty(adExtension) { | |
export function isEmptyExtension(adExtension) { |
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 also agree it needs renaming
src/parser/ad_parser.js
Outdated
@@ -329,20 +329,20 @@ function _parseExtension(extNode) { | |||
} | |||
|
|||
// Only return not empty objects to not pollute extentions | |||
return ext.isEmpty() ? null : ext; | |||
return isEmpty(ext) ? null : ext; |
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.
with the renaming, it will be much more explicit here while reading the code
src/vast_tracker.js
Outdated
@@ -65,7 +65,7 @@ export class VASTTracker extends EventEmitter { | |||
// Nonlinear and companion creatives provide some tracking information at a variation level | |||
// While linear creatives provided that at a creative level. That's why we need to | |||
// differentiate how we retrieve some tracking information. | |||
if (this.creative instanceof CreativeLinear) { | |||
if (this.creative instanceof createCreativeLinear) { |
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.
This will not work, probably need a function next to createCreativeLinear
which is isCreativeLinear
and this will check that this plain object contain all linear creative property
src/ad_extension.js
Outdated
this.children.length === 0 | ||
); | ||
} | ||
export function isEmpty(adExtension) { |
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 also agree it needs renaming
5c35181
to
f3e74ae
Compare
f3e74ae
to
7fd2377
Compare
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.
One last comment have a commented import
to remove.
Thanks a lot for your contribution 👍 ⭐️
test/vast_parser.js
Outdated
@@ -2,10 +2,11 @@ import path from 'path'; | |||
import should from 'should'; | |||
import sinon from 'sinon'; | |||
import { VASTParser } from '../src/parser/vast_parser'; | |||
import { VASTResponse } from '../src/vast_response'; | |||
// import { createVASTResponse } from '../src/vast_response'; |
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.
this line should be removed right ?
src/companion_ad.js
Outdated
}; | ||
} | ||
|
||
export function isCompanionAd(companionAd) { |
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.
you named the param companionAd
but it might not be one. I would rename it to ad
or adVariation
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.
same for the other functions
test/vast_parser.js
Outdated
@@ -137,7 +137,7 @@ describe('VASTParser', function() { | |||
}); | |||
|
|||
it('should have returned a VAST response object', () => { | |||
this.response.should.be.an.instanceOf(VASTResponse); | |||
isVASTResponse(this.response).should.eql(true); |
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 don't think it is a good idea to introduce a function in the production code just for unit tests. You should instead make sure that this.response
has the correct properties with the correct values explicitly in the unit test.
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.
LGTM! Only thing left is to fix the conflicts :)
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.
Thanks 💯
🚢 !
Description
Refactor for performance improvements.
Issue
Replacing classes with objects. #317
Type