-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from jpgorman/addWithoutMethod
Add without method
- Loading branch information
Showing
4 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,11 @@ | ||
const R = require('../rambda') | ||
|
||
describe('without', () => { | ||
it('should return a new list without values in the first argument ', () => { | ||
const itemsToOmit = ['A', 'B', 'C'] | ||
const collection = ['A', 'B', 'C', 'D', 'E', 'F'] | ||
expect( | ||
R.without(itemsToOmit, collection) | ||
).toEqual([ 'D', 'E', 'F' ]) | ||
}) | ||
}) |
This file contains 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 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,6 @@ | ||
import contains from './contains' | ||
import reduce from './reduce' | ||
|
||
export default function without(itemsToOmit, collection) { | ||
return reduce((accum, item) => !contains(item, itemsToOmit) ? accum.concat(item) : accum, [], collection) | ||
} |
This file contains 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