diff --git a/exports.tsx b/exports.tsx index d3e5d83..1e2ad49 100755 --- a/exports.tsx +++ b/exports.tsx @@ -1,13 +1,15 @@ export { FieldLoading } from "@/comps/ui/field-loading"; import { lazify, lazifyMany } from "@/utils/lazify"; import __get from "lodash.get"; +import { sum } from "./utils/sum"; export { guessLabel } from "./utils/guess-label"; export { fetchLinkParams } from "./comps/form/field/type/TypeLink"; export { prasi_gen } from "./gen/prasi_gen"; +export const _sum = sum; export const _get = __get; -export const Accordion = lazify( +export const Accordion = lazify( async () => (await import("@/comps/ui/accordion")).Accordion ); diff --git a/utils/sum.ts b/utils/sum.ts new file mode 100755 index 0000000..588ab27 --- /dev/null +++ b/utils/sum.ts @@ -0,0 +1,7 @@ +import get from "lodash.get"; + +export const sum = (items: any[], keyName: string) => { + return items.reduce(function (a, b) { + return (Number(a) || 0) + (Number(get(b, keyName)) || 0); + }, 0); +};