Created
June 16, 2020 12:23
-
-
Save XiongLiding/0c6da3b3b8cb9cc3ef7e4bdb3325d746 to your computer and use it in GitHub Desktop.
通过递归实现任意级别的分组功能,第一个参数是作为分组依据的函数的数组,第二个参数是初始的数据数组
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
const { map, groupBy } = require("rambda"); | |
const nestGroupBy = ([fn, ...fns], list) => { | |
if (!fn) { | |
return list; | |
} | |
const g = groupBy(fn, list); | |
return map(v => { | |
return nestGroupBy(fns, v); | |
}, g); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment