Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bharathvaj-ganesan
Copy link

Bump the major version

@sturdynut
Copy link
Owner

@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:

  • I'd like to keep it 2 spaced vs it all being 4 spaced.
  • Wouldn't be a bad idea to add a .eslintrc to enforce this.

}

module.exports = (new RandomCat());
Copy link
Owner

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.

Copy link
Author

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();
Copy link
Owner

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();

Copy link
Author

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this.

Copy link
Author

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'
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Author

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?

Copy link
Owner

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.

@sturdynut
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants