Skip to content

Commit

Permalink
Merge pull request #42 from jpgorman/addWithoutMethod
Browse files Browse the repository at this point in the history
Add without method
  • Loading branch information
selfrefactor authored Oct 10, 2017
2 parents 5450754 + a4c5955 commit a6f20ad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions __tests__/without.js
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' ])
})
})
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ declare namespace R {
update<T>(index: number, value: T): (list: T[]) => T[];

values<T extends object, K extends keyof T>(obj: T): Array<T[K]>;
without(listToOmit: any[], originalList: any[]): list: any[];
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/without.js
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)
}
1 change: 1 addition & 0 deletions rambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ export { default as typedDefaultTo } from './modules/typedDefaultTo'
export { default as uniq } from './modules/uniq'
export { default as update } from './modules/update'
export { default as values } from './modules/values'
export { default as without } from './modules/without'

0 comments on commit a6f20ad

Please sign in to comment.