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

Add ability to pass multiple keywords #13

Merged
merged 2 commits into from
Nov 19, 2017

Conversation

mischah
Copy link
Contributor

@mischah mischah commented Nov 3, 2017

This will close #12

Copy link
Contributor Author

@mischah mischah left a comment

Choose a reason for hiding this comment

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

Can I has review?

}

if (options.size < 1 || options.size > 250) {
return Promise.reject(new TypeError('Size option must be between 1 and 250'));
}

keyword = encodeURIComponent(keyword);
keyword = encodeURIComponent(keyword).replace('%2C', '+');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this to »clever«? 😎

Copy link
Owner

Choose a reason for hiding this comment

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

Why are you doing it? From the docs:

separate multiple keywords with commas

So that should be + => ,, but have you tested whether it supports encoded comma or not?

Copy link
Contributor Author

@mischah mischah Nov 4, 2017

Choose a reason for hiding this comment

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

The docs are wrong misleading (Going to create a PR to fix thisSee https://github.com/npm/registry/pull/235).

Combining keywords with , acts like a || while combining them with + acts like a &&.

So we need to use a + in our use case.

Compare the following:
keywords:yeoman-generator ➡️ "total": 6994
keywords:yeoman-generator,baumeister ➡️ "total": 6994
keywords:yeoman-generator+baumeister ➡️ "total": 1
keywords:yeoman-generator,-baumeister ➡️ "total": 6993

test.js Outdated
@@ -61,3 +61,17 @@ test('npmKeyword.count()', async t => {
t.is(typeof cnt1, 'number');
t.is(cnt2, 0);
});

test('npmKeyword.count() using an array of keywords', async t => {
Copy link
Contributor Author

@mischah mischah Nov 3, 2017

Choose a reason for hiding this comment

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

Would love to test the part of the URL separately.
But that would mean to move some code to lib/search-url.js, right?

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make the testing the correct URL creation independent of the API and the response.
I’m not sure if this is necessary 🤔

What do you mean?

}

if (options.size < 1 || options.size > 250) {
return Promise.reject(new TypeError('Size option must be between 1 and 250'));
}

keyword = encodeURIComponent(keyword);
keyword = encodeURIComponent(keyword).replace('%2C', '+');
Copy link
Owner

Choose a reason for hiding this comment

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

Why are you doing it? From the docs:

separate multiple keywords with commas

So that should be + => ,, but have you tested whether it supports encoded comma or not?

test.js Outdated
@@ -61,3 +61,17 @@ test('npmKeyword.count()', async t => {
t.is(typeof cnt1, 'number');
t.is(cnt2, 0);
});

test('npmKeyword.count() using an array of keywords', async t => {
Copy link
Owner

Choose a reason for hiding this comment

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

test.js Outdated
@@ -61,3 +61,17 @@ test('npmKeyword.count()', async t => {
t.is(typeof cnt1, 'number');
t.is(cnt2, 0);
});

test('npmKeyword.count() using an array of keywords', async t => {
const cnt1 = await m.count('gulpplugin');
Copy link
Owner

Choose a reason for hiding this comment

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

cnt1 is not a readable variable name. Use something more verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@mischah
Copy link
Contributor Author

mischah commented Nov 6, 2017

This could get another round of review 😗

@mischah
Copy link
Contributor Author

mischah commented Nov 12, 2017

This could get another round of review 😗

Pretty please 😘

And please let me know if I annoy you with this one. I can imagine that you have tons of other issues, PRs and own ideas you would like to work on. It’s just that I really want this to happen to be able to work on yeoman/yo#544.

@sindresorhus
Copy link
Owner

Thanks for your patience. I was away on vacation.

@sindresorhus sindresorhus merged commit 4ded5ad into sindresorhus:master Nov 19, 2017
sindresorhus added a commit that referenced this pull request Nov 19, 2017
@mischah
Copy link
Contributor Author

mischah commented Nov 19, 2017

No problem. Thanks for taking care.

@mischah mischah deleted the multiple-keywords branch November 19, 2017 09:57
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.

Feature: Pass a string or an array of keywords
2 participants