Skip to content

update code to es6 #1

Open
bharathvaj-ganesan wants to merge 5 commits intosturdynut:masterfrom
bharathvaj-ganesan:master
Open

update code to es6 #1
bharathvaj-ganesan wants to merge 5 commits intosturdynut:masterfrom
bharathvaj-ganesan:master

Conversation

@bharathvaj-ganesan
Copy link
Copy Markdown

Bump the major version

@sturdynut
Copy link
Copy Markdown
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.

Comment thread index.js
}
}

module.exports = (new RandomCat()); No newline at end of file
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread README.md
// 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
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

fine.

Comment thread index.js
options = options || {};

if (options.dummyText) {
options.dummyText = escape(options.dummyText);
Copy link
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

cool

Comment thread index.js
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
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

okay

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread index.js
Comment thread index.js
@sturdynut
Copy link
Copy Markdown
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