-
-
Notifications
You must be signed in to change notification settings - Fork 453
Add .pick()
and .exclude()
#282
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ac21b22
Add `.filterElements()`
Richienb 8b3c1ab
Merge branch 'master' into filter-elements
Richienb 4167668
Use `Object.assign`
Richienb 8199278
Use older version of `filter-obj` to remain compatible
Richienb 46f70ef
Update index.d.ts
Richienb dc8f636
Update documentation
Richienb 9d6d263
Update filter-elements.js
sindresorhus 7e8e91b
Update readme.md
sindresorhus 33f0b95
Update index.d.ts
sindresorhus b18296c
Update documentation
Richienb b019bc0
Rename to `.filter()`
Richienb d741bae
Change `.filter` to `.pick` and `.exclude`
Richienb 69dc0c3
Update index.d.ts
Richienb cca0eba
Meta tweaks
Richienb 969e04d
Update index.d.ts
Richienb 33d0a68
Update readme.md
sindresorhus 19917bf
Update readme.md
Richienb 0cb2fb4
Update readme.md
Richienb 61ec390
Create readme.md
Richienb 0896e90
Update index.js
Richienb 9bc2052
Update index.js
Richienb a128265
Update index.js
Richienb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import test from 'ava'; | ||
import queryString from '..'; | ||
|
||
test('excludes elements in a URL with a filter array', t => { | ||
t.is(queryString.exclude('http://example.com/?a=1&b=2&c=3#a', ['c']), 'http://example.com/?a=1&b=2#a'); | ||
}); | ||
|
||
test('excludes elements in a URL with a filter predicate', t => { | ||
t.is(queryString.exclude('http://example.com/?a=1&b=2&c=3#a', (name, value) => { | ||
t.is(typeof name, 'string'); | ||
t.is(typeof value, 'number'); | ||
|
||
return name === 'a'; | ||
}, { | ||
parseNumbers: true | ||
}), 'http://example.com/?b=2&c=3#a'); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import test from 'ava'; | ||
import queryString from '..'; | ||
|
||
test('picks elements in a URL with a filter array', t => { | ||
t.is(queryString.pick('http://example.com/?a=1&b=2&c=3#a', ['a', 'b']), 'http://example.com/?a=1&b=2#a'); | ||
}); | ||
|
||
test('picks elements in a URL with a filter predicate', t => { | ||
t.is(queryString.pick('http://example.com/?a=1&b=2&c=3#a', (name, value) => { | ||
t.is(typeof name, 'string'); | ||
t.is(typeof value, 'number'); | ||
|
||
return name === 'a'; | ||
}, { | ||
parseNumbers: true | ||
}), 'http://example.com/?a=1#a'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.