bulk-query
This commit is contained in:
parent
69200c0ae5
commit
71879f81b1
|
|
@ -15,7 +15,6 @@ export const Dialog = lazify(
|
|||
async () => (await import("@/comps/ui/dialog")).Dialog
|
||||
);
|
||||
|
||||
|
||||
export const Typeahead = lazify(
|
||||
async () => (await import("@/comps/ui/typeahead")).Typeahead
|
||||
);
|
||||
|
|
@ -106,7 +105,7 @@ export const Import = lazify(
|
|||
export const Sheet = lazify(
|
||||
async () => (await import("@/comps/sheet/sheet")).SheetCn
|
||||
);
|
||||
export {formatBytes} from "@/comps/import/lib/formatBytes"
|
||||
export { formatBytes } from "@/comps/import/lib/formatBytes";
|
||||
export { fetchLinkParams } from "@/comps/form/field/type/TypeLink";
|
||||
export { FieldLoading, Spinner } from "@/comps/ui/field-loading";
|
||||
export { lang } from "lib/lang";
|
||||
|
|
@ -121,7 +120,7 @@ export { toast, Toaster } from "./comps/ui/toast";
|
|||
export { NavLink } from "./comps/popup/NavLink";
|
||||
export { kvToJSON } from "./utils/kv-to-json";
|
||||
export { overrideNav } from "./utils/override-nav";
|
||||
|
||||
export { bulk_query } from "./utils/bulk-query";
|
||||
export const _sum = sum;
|
||||
export const _get = __get;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
export const bulk_query = async ({
|
||||
list,
|
||||
task,
|
||||
}: {
|
||||
list: any[];
|
||||
task: (e: any, index?: number) => Promise<void>;
|
||||
}) => {
|
||||
const recursive = async (data: any, list: Array<any>, index: number) => {
|
||||
if (list.length) {
|
||||
await task(data, index);
|
||||
index++;
|
||||
if (index <= list.length - 1) {
|
||||
await recursive(list[index], list, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
await recursive(list[0], list, 0);
|
||||
};
|
||||
Loading…
Reference in New Issue