import { clone } from '../clone' ; import { curry3 } from '@typed/functions' ; name export const set = curry3 ( function __set < Key extends PropertyKey , A , O extends { readonly : { [ K in Key ] : A ; } ; } > ( key , value , obj ) : O { const clonedObj = clone ( obj ) ; ( clonedObj as any ) [ key ] = value ; return clonedObj ; } ) as SetArity3 ; export type SetArity3 = { < A , O extends { readonly [ key ] : A ; } > ( key , value , obj ) : O ; < Key extends PropertyKey , A , O extends Readonly < Record < Key , A > > > ( key , value , obj ) : O ; < A > ( key , value ) : < O extends { readonly [ key ] : A ; } > ( obj : O ) => O ; < Key extends PropertyKey , A > ( key , value ) : SetArity1 < Key , A > ; ( key ) : SetArity2Number ; < Key extends PropertyKey > ( key ) : SetArity2 < Key > ; } ; export type SetArity2Number = { < A , O extends { readonly [ key ] : A ; } > ( value , obj ) : O ; < A > ( value ) : < O extends { readonly [ key ] : A ; } > ( obj : O ) => O ; < A , O extends { readonly [ key ] : A ; } > ( value ) : ( obj : O ) => O ; } ; export type SetArity2 < Key extends PropertyKey > = { < A , O extends Readonly < Record < Key , A > > > ( value , obj ) : O ; < A > ( value ) : SetArity1 < Key , A > ; } ; export type SetArity1 < Key extends PropertyKey , A > = { < O extends Readonly < Record < Key , A > > > ( obj ) : O ; } ;