refactor: remove useBaseFetch for @modrinth/api-client (#5596)
* Reapply "fix: start swapping useBaseFetch usages to api-client" This reverts commit f4f33db7019ea861addb2c66c204d736800b7b6c. * fix: bugs * fix: analytics * fix: lint
This commit is contained in:
@@ -21,6 +21,16 @@ export function fetchSegmented<T>(
|
||||
).then((results) => results.flat())
|
||||
}
|
||||
|
||||
export function fetchSegmentedWith<TId, TResult>(
|
||||
data: TId[],
|
||||
fetchFn: (ids: TId[]) => Promise<TResult[]>,
|
||||
segmentSize = 800,
|
||||
): Promise<TResult[]> {
|
||||
return Promise.all(segmentData(data, segmentSize).map((ids) => fetchFn(ids))).then((results) =>
|
||||
results.flat(),
|
||||
)
|
||||
}
|
||||
|
||||
export function asEncodedJsonArray<T>(data: T[]): string {
|
||||
return encodeURIComponent(JSON.stringify(data))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user