MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeCombiner

Function makeCombiner

packages/effect/src/Struct.ts:883–900  ·  view source on GitHub ↗
(
  combiners: { readonly [K in keyof A]: Combiner.Combiner<A[K]> },
  options?: {
    readonly omitKeyWhen?: ((a: A[keyof A]) => boolean) | undefined
  }
)

Source from the content-addressed store, hash-verified

881 * @since 4.0.0
882 */
883export function makeCombiner<A>(
884 combiners: { readonly [K in keyof A]: Combiner.Combiner<A[K]> },
885 options?: {
886 readonly omitKeyWhen?: ((a: A[keyof A]) => boolean) | undefined
887 }
888): Combiner.Combiner<A> {
889 const omitKeyWhen = options?.omitKeyWhen ?? (() => false)
890 return Combiner.make((self, that) => {
891 const keys = Reflect.ownKeys(combiners) as Array<keyof A>
892 const out = {} as A
893 for (const key of keys) {
894 const merge = combiners[key].combine(self[key], that[key])
895 if (omitKeyWhen(merge)) continue
896 InternalRecord.assignProperty(out as object, key, merge)
897 }
898 return out
899 })
900}
901
902/**
903 * Creates a `Reducer` for a struct shape by providing a `Reducer` for each

Callers 1

makeReducerFunction · 0.70

Calls 2

makeMethod · 0.65
combineMethod · 0.65

Tested by

no test coverage detected