(
reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]> },
options?: {
readonly omitKeyWhen?: ((a: A[keyof A]) => boolean) | undefined
}
)
| 938 | * @since 4.0.0 |
| 939 | */ |
| 940 | export function makeReducer<A>( |
| 941 | reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]> }, |
| 942 | options?: { |
| 943 | readonly omitKeyWhen?: ((a: A[keyof A]) => boolean) | undefined |
| 944 | } |
| 945 | ): Reducer.Reducer<A> { |
| 946 | const combine = makeCombiner(reducers, options).combine |
| 947 | const initialValue = {} as A |
| 948 | for (const key of Reflect.ownKeys(reducers) as Array<keyof A>) { |
| 949 | const iv = reducers[key].initialValue |
| 950 | if (options?.omitKeyWhen?.(iv)) continue |
| 951 | InternalRecord.assignProperty(initialValue as object, key, iv) |
| 952 | } |
| 953 | return Reducer.make(combine, initialValue) |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * Creates a record with the given keys and value. |
nothing calls this directly
no test coverage detected