reorg, remove old music slice files

This commit is contained in:
austinried
2022-03-20 16:16:16 +09:00
parent 2969b6c768
commit ba37348fc3
23 changed files with 139 additions and 345 deletions

17
app/util/state.ts Normal file
View File

@@ -0,0 +1,17 @@
import { ById } from '@app/models/state'
import merge from 'lodash.merge'
export function reduceById<T extends { id: string }>(collection: T[]): ById<T> {
return collection.reduce((acc, value) => {
acc[value.id] = value
return acc
}, {} as ById<T>)
}
export function mergeById<T extends { [id: string]: unknown }>(object: T, source: T): void {
merge(object, source)
}
export function mapById<T>(object: ById<T>, ids: string[]): T[] {
return ids.map(id => object[id]).filter(a => a !== undefined)
}