fetch breadcrumbs from api; button disabled support; component fix

This commit is contained in:
tmshv committed 2020-02-23 04:29:26 +03:00
1 parent 26c03dfbbf
commit aefa0ae2d4
9 files changed
+94 -50

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
export function splitBy(fn) {
return items => {
return items.reduce((acc, item) => {
const key = fn(item)
const items = acc.get(key) || []
return acc.set(key, [...items, item])
}, new Map())
}
}
export function insertBetween<T, I = T>(items: T[], fn: (i: number) => I): Array<T | I> {
return items.reduce((acc, x, i) => {
acc.push(x)
if (i < items.length - 1) {
acc.push(fn(i))
}
return acc
}, [])
}