Skip to content

Commit

Permalink
refactor(#174): refactor omitIndexes
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma2 committed Oct 23, 2017
1 parent 3af8d6f commit 299c257
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/omitIndexes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reject, addIndex, curryN, contains } from 'ramda';
import { contains, curry, addIndex, reject } from 'ramda';

/**
* Returns a partial copy of an array omitting the indexes specified.
Expand All @@ -16,11 +16,11 @@ import { reject, addIndex, curryN, contains } from 'ramda';
*
* RA.omitIndexes([-1, 1, 3], ['a', 'b', 'c', 'd']); //=> ['a', 'c']
*/
const indexedReject = addIndex(reject);

const omitIndexes = curryN(2, (indexes, list) => {
const rejectIndexes = (_, i) => contains(i, indexes);
return indexedReject(rejectIndexes, list);
});
// helpers
const rejectIndexed = addIndex(reject);
const containsIndex = curry((indexes, val, index) => contains(index, indexes));

const omitIndexes = curry((indexes, list) => rejectIndexed(containsIndex(indexes), list));

export default omitIndexes;

0 comments on commit 299c257

Please sign in to comment.