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 .pick() and .exclude() #282

Merged
merged 22 commits into from
Feb 10, 2021
Merged

Conversation

Richienb
Copy link
Contributor

@Richienb Richienb commented Oct 3, 2020

Fixes: #259

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Richienb Richienb marked this pull request as draft October 3, 2020 01:07
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Richienb Richienb marked this pull request as ready for review October 3, 2020 01:34
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@sindresorhus
Copy link
Owner

What's the reasoning for going with a single method instead of pick/exclude? Just curious. And why .filterElements() over .filter()?

index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@Richienb
Copy link
Contributor Author

What's the reasoning for going with a single method instead of pick/exclude? Just curious. And why .filterElements() over .filter()?

I took inspiration for naming from #259 (comment)

Richienb and others added 2 commits October 14, 2020 17:17
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
index.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

I took inspiration for naming from #259 (comment)

That was a response to other naming suggestions. I think just .filter() is clear enough in this case.

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

For a better implementation, this could preserve the order of url queries, cause input and output are both strings, which has order. - #259 (comment)

Can you add a test for that?

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Richienb Richienb changed the title Add .filterElements() Add .filter() Oct 17, 2020
@Richienb
Copy link
Contributor Author

Can you add a test for that?

If you mean the order of query parameters, that is already tested.

@sindresorhus
Copy link
Owner

Which is why the original suggestion was to add .pick() and .exclude() methods, which I still prefer.

@Richienb Any thoughts on this? I think that might be a better API for this.

@Richienb
Copy link
Contributor Author

@sindresorhus I am waiting on sindresorhus/filter-obj#9 to implement this.

Base automatically changed from master to main January 24, 2021 06:08
@sindresorhus
Copy link
Owner

I am waiting on sindresorhus/filter-obj#9 to implement this.

I don't have time to do sindresorhus/filter-obj#9 and doesn't look like anyone else has either, so should we close this PR for now? It's stale and doesn't seem like something will happen here anytime soon.

@Richienb
Copy link
Contributor Author

Richienb commented Feb 1, 2021

@sindresorhus I guess I'll tackle the issue myself.

Since specifying keys to be included and excluded is mutually exclusive, should I add it as a separate option in filter-obj instead of exclamation marks?

@sindresorhus
Copy link
Owner

Sure

@Richienb Richienb changed the title Add .filter() Add .pick() and .exclude() Feb 5, 2021
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
Richienb and others added 2 commits February 8, 2021 01:19
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
readme.md Outdated Show resolved Hide resolved
readme.md Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
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 request: query-string strip (pick, exclude)
2 participants