Created
July 26, 2018 23:36
-
-
Save stefanmaric/9e5191c7c19a3ae2200830ae6254f574 to your computer and use it in GitHub Desktop.
Alternatives for exclusion with lodash
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
import * as _ from 'lodash' | |
const exclusion = (...arrays) => | |
_.flatMap(arrays, x => _.difference(x, ..._.without(arrays, x))) |
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
import * as _ from 'lodash' | |
const exclusion = (...arrays) => | |
_.difference( | |
_.union(...arrays), | |
_.flattenDepth( | |
_.map(arrays, x => | |
_.map(_.without(arrays, x), y => _.intersection(x, y)) | |
), | |
2 | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment