How to use the updeep.reject 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
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
function removeAccount(state, accountId) {
    assert(
        typeof accountId === 'number',
        'second parameter of removeAccount should be a number id'
    );

    let account = accountById(state, accountId);
    // First remove the attached operations from the operation map.
    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);
github kresusapp / kresus / client / store / banks.js View on Github external
);

    let op = operationById(state, operationId);
    let account = accountById(state, op.accountId);

    let { balance, outstandingSum } = account;
    let today = moment();

    if (shouldIncludeInBalance(op, today, account.type)) {
        balance -= op.amount;
    } else if (shouldIncludeInOutstandingSum(op)) {
        outstandingSum -= op.amount;
    }

    let newState = updateAccountFields(state, account.id, {
        operationIds: u.reject(id => id === operationId),
        balance,
        outstandingSum
    });

    return updateOperationsMap(newState, u.omit(`${operationId}`));
}
github kresusapp / kresus / client / store / categories.js View on Github external
function reduceDelete(state, action) {
    let { status } = action;

    if (status === SUCCESS) {
        let id = action.id;
        return u(
            {
                items: u.reject(c => c.id === id),
                map: u.omit(id)
            },
            state
        );
    }

    return state;
}
github gilbox / react-imation / examples / demo1 / Game.js View on Github external
    removeFlake: flakeId => edit(u({flakes: u.reject(flakeHasId(flakeId)) })),
    explodeFlake: index => edit(u({flakes: { [index]: { explode: true } } })),

updeep

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

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis