How to use the updeep function in updeep

To help you get started, we’ve selected a few updeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kresusapp / kresus / client / store / banks.js View on Github external
let newState = updateOperationsMap(state, u.omit(account.operationIds));

    // Then remove the account from the access.
    newState = updateAccessFields(newState, account.accessId, {
        accountIds: u.reject(id => id === accountId)
    });

    // Remove access if no more accounts in the access.
    newState =
        accountIdsByAccessId(newState, account.accessId).length === 0
            ? removeAccess(newState, account.accessId)
            : newState;

    // Reset the defaultAccountId if we just deleted it.
    if (getDefaultAccountId(newState) === accountId) {
        newState = u({ defaultAccountId: DefaultSettings.get('default-account-id') }, newState);
    }

    // Reset the current account id if we just deleted it.
    if (getCurrentAccountId(newState) === accountId) {
        newState = setCurrentAccessAndAccount(newState);
    }

    // Remove alerts attached to the account.
    newState = u.updateIn('alerts', u.reject(alert => alert.accountId === accountId), newState);

    // Finally, remove the account from the accounts map.
    return updateAccountsMap(newState, u.omit(accountId));
}
github kresusapp / kresus / client / store / banks.js View on Github external
export function initialState(external, allAccesses, allAccounts, allOperations, allAlerts) {
    // Retrieved from outside.
    let { defaultCurrency, defaultAccountId } = external;

    if (defaultAccountId !== DefaultSettings.get('default-account-id')) {
        defaultAccountId = parseInt(defaultAccountId, 10);
    }

    let banks = StaticBanks.map(b => new Bank(b));
    sortBanks(banks);

    let newState = u(
        {
            banks,
            constants: {
                defaultCurrency
            },
            defaultAccountId
        },
        INITIAL_STATE
    );

    newState = addAccesses(newState, allAccesses, allAccounts, allOperations);
    newState = setCurrentAccessAndAccount(newState);

    let alerts = allAlerts.map(al => new Alert(al));

    return u(
github experimentalDataAesthetics / play-splom / app / reducers / mapping.js View on Github external
export function setMapping(state, action) {
  return u(
    {
      [action.payload.feature]: {
        param: action.payload.param
      }
    },
    state
  );
}
github TryStarboard / Starboard / source / client / reducers / filters.js View on Github external
export default function (state = [], {type, payload}) {
  switch (type) {
  case SELECT_TAG:
    return u(
      u.ifElse(
        contains(payload.tagId),
        without([payload.tagId]),
        append(payload.tagId)
      ),
      state
    );
  case `${DELETE_TAG}_PENDING`:
    return reject(equals(payload.tagId), state);
  case REMOVE_FILTER:
    return without([payload.tagId], state);
  default:
    return state;
  }
}
github kresusapp / kresus / client / store / ui.js View on Github external
return function(state, action) {
        let { status } = action;
        if (status === FAIL || status === SUCCESS) {
            return u({ processingReason: null }, state);
        }
        return u({ processingReason }, state);
    };
}
github kresusapp / kresus / client / store / banks.js View on Github external
function reduceUpdateAlert(state, action) {
    let { status } = action;

    if (status === SUCCESS) {
        let { attributes, alertId } = action;
        return u.updateIn('alerts', updateMapIf('id', alertId, u(attributes)), state);
    }

    return state;
}
github kresusapp / kresus / client / store / budgets.js View on Github external
let { status } = action;

    if (status === SUCCESS) {
        return u(
            {
                budgetsByPeriod: {
                    [`${action.year}${action.month}`]: action.budgets.map(b => new Budget(b))
                }
            },
            state
        );
    }

    if (status === FAIL) {
        genericErrorHandler(action.error);
        return u(
            {
                budgetsByPeriod: {
                    [`${action.year}${action.month}`]: null
                }
            },
            state
        );
    }

    return state;
}
github ktmouk / hackaru-desktop / src / renderer / store / modules / auth-api.js View on Github external
async request({ dispatch, rootGetters }, config) {
    const accessToken = rootGetters['auth/getAccessToken'];
    return dispatch(
      'api/request',
      u(config, {
        headers: {
          Authorization: `Bearer ${accessToken}`
        }
      }),
      { root: true }
    );
  }
};
github kresusapp / kresus / client / store / settings.js View on Github external
function reduceGetWeboobVersion(state, action) {
    let { status } = action;

    if (status === SUCCESS) {
        let stateUpdates = { map: { 'weboob-version': action.version } };

        if (typeof action.isInstalled === 'boolean') {
            if (!action.isInstalled) {
                notify.error($t('client.sync.weboob_not_installed'));
            }
            stateUpdates.map['weboob-installed'] = action.isInstalled.toString();
        }

        return u(stateUpdates, state);
    }

    if (status === FAIL) {
        if (action.error.code === Errors.WEBOOB_NOT_INSTALLED) {
            notify.error($t('client.sync.weboob_not_installed'));
            return u({ map: { 'weboob-installed': 'false' } }, state);
        }

        genericErrorHandler(action.error);
        return u({ map: { 'weboob-version': null } }, state);
    }

    return state;
}
github kresusapp / kresus / client / store / ui.js View on Github external
export function initialState(isDemoEnabled) {
    let search = initialSearch();
    return u(
        {
            search,
            displaySearchDetails: false,
            processingReason: 'client.general.loading_assets',
            updatingWeboob: false,
            sendingTestEmail: false,
            isDemoMode: isDemoEnabled,
            isExporting: false,
            isSmallScreen: computeIsSmallScreen(),
            modal: {
                slug: null,
                state: null
            },
            isMenuHidden: computeIsSmallScreen()
        },
        {}

updeep

Easily update nested frozen objects and arrays in a declarative and immutable manner.

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis