* Gets an updated root value to use when setting a value on a deepSignal with the given path. * @param sourceValue The current value of the deepSignal's source. * @param newPropValue The value being written to the deepSignal's property * @param prop The deepSignal's property key * @returns An up
(sourceValue: unknown, newPropValue: unknown, prop: PropertyKey)
| 49 | * @returns An updated value for the deepSignal's source |
| 50 | */ |
| 51 | function valueForWrite(sourceValue: unknown, newPropValue: unknown, prop: PropertyKey): unknown { |
| 52 | if (isArray(sourceValue)) { |
| 53 | const newValue = [...sourceValue]; |
| 54 | newValue[prop as number] = newPropValue; |
| 55 | return newValue; |
| 56 | } else { |
| 57 | return {...(sourceValue as object), [prop]: newPropValue}; |
| 58 | } |
| 59 | } |
no test coverage detected
searching dependent graphs…