-
Notifications
You must be signed in to change notification settings - Fork 1
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
update code to es6 #1
base: master
Are you sure you want to change the base?
Conversation
@bharathvaj1995 - Appreciate you modernizing this library a bit. I've made note of a couple changes I'd like to see prior to merging. Style-wise:
|
} | ||
|
||
module.exports = (new RandomCat()); |
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'd leave the (new RandomCat())
. By removing the new RandomCat()
it changes the interface. This breaks compatibility and would require a major and/or minor version update.
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.
will change and push
@@ -20,33 +22,33 @@ var randomCat = require('random-cat'); | |||
// Random cat picture of various widths and heights | |||
// Possible values: 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600 | |||
// http://lorempixel.com/100/600/cats | |||
var url = randomCat.get(); | |||
var url = new randomCat.get(); |
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 is why I want to leave the new RandomCat()
, to avoid all these new objects. If we were to keep it without the new RandomCat()
, rather than what you've done here, it'd be more appropriate to do this:
const randomCat = new RandomCat();
const url = randomCat.get();
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.
options = options || {}; | ||
|
||
if (options.dummyText) { | ||
options.dummyText = escape(options.dummyText); |
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.
We should keep this.
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.
cool
options.gray ? 'g' : false | ||
, options.width || randomSizes[Math.ceil(Math.random() * 12)] | ||
, options.height || randomSizes[Math.ceil(Math.random() * 12)] | ||
, options.category || 'cats' |
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 believe you've lost the category and default here...'cats' being the default is pretty important
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.
okay
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.
since this is an exclusive random cat category ... why do we need to give category option?
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.
It's not a good thing to change what options you can pass. If someone had been using "Dogs" or anything else, it would break that.
You are right though, this is a random cat lib, so why give another option? I think in this case it is the principal of backward compatibility.
Just curious...how did you find this lib and what prompted you to rewrite it w/es6? Are you using this lib? I really appreciate you taking the time to modernize this, so thank you! |
Bump the major version