(
combiners: { readonly [K in keyof A]: Combiner.Combiner<A[K]> },
options?: {
readonly omitKeyWhen?: ((a: A[keyof A]) => boolean) | undefined
}
)
| 881 | * @since 4.0.0 |
| 882 | */ |
| 883 | export 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 |
no test coverage detected