export function recursiveDestructuringNestedUpdater(prevState, keyArray, finalNestedState) {
    const [key, ...remainingKeys] = keyArray;
    const nextNestedState = remainingKeys.length === 0
        ? finalNestedState
        : recursiveDestructuringNestedUpdater(prevState[key], remainingKeys, finalNestedState);
    if (Array.isArray(prevState)) {
        const result = prevState.map((item, index) => index === key ? nextNestedState : item);
        return result;
    }
    else {
        return Object.assign(Object.assign({}, prevState), { [key]: nextNestedState });
    }
}
