sdk/src/sync/operations.js
function getCondenseAction(pendingOperation, newAction) {
        
        var pendingAction = pendingOperation.action,
            condenseAction;
        if (pendingAction === 'insert' && newAction === 'update') {
            condenseAction = 'nop';
        } else if (pendingAction === 'insert' && newAction === 'delete') {
            condenseAction = 'remove';
        } else if (pendingAction === 'update' && newAction === 'update') {
            condenseAction = 'nop';
        } else if (pendingAction === 'update' && newAction === 'delete') {
            condenseAction = 'modify';
        } else if (pendingAction === 'delete' && newAction === 'delete') {
            condenseAction = 'nop';
        } else if (pendingAction === 'delete') {
            throw new Error('Operation ' + newAction + ' not supported as a DELETE operation is pending'); //TODO: Limitation on all client SDKs
        } else {
            throw new Error('Condense not supported when pending action is ' + pendingAction + ' and new action is ' + newAction);
        }
        
        if (isLocked(pendingOperation)) {
            condenseAction = 'add';
        }
        
        return condenseAction;
    }
function getCondenseAction(pendingOperation, newAction) {
        
        var pendingAction = pendingOperation.action,
            condenseAction;
        if (pendingAction === 'insert' && newAction === 'update') {
            condenseAction = 'nop';
        } else if (pendingAction === 'insert' && newAction === 'delete') {
            condenseAction = 'remove';
        } else if (pendingAction === 'update' && newAction === 'update') {
            condenseAction = 'nop';
        } else if (pendingAction === 'update' && newAction === 'delete') {
            condenseAction = 'modify';
        } else if (pendingAction === 'delete' && newAction === 'delete') {
            condenseAction = 'nop';
        } else if (pendingAction === 'delete') {
            throw new Error('Operation ' + newAction + ' not supported as a DELETE operation is pending'); //TODO: Limitation on all client SDKs
        } else {
            throw new Error('Condense not supported when pending action is ' + pendingAction + ' and new action is ' + newAction);
        }
        
        if (isLocked(pendingOperation)) {
            condenseAction = 'add';
        }
        
        return condenseAction;
    }
function getCondenseAction ( pendingOperation , newAction ) { var pendingAction = pendingOperation . action , condenseAction ; if ( pendingAction === 'insert' && newAction === 'update' ) { condenseAction = 'nop' ; } else if ( pendingAction === 'insert' && newAction === 'delete' ) { condenseAction = 'remove' ; } else if ( pendingAction === 'update' && newAction === 'update' ) { condenseAction = 'nop' ; } else if ( pendingAction === 'update' && newAction === 'delete' ) { condenseAction = 'modify' ; } else if ( pendingAction === 'delete' && newAction === 'delete' ) { condenseAction = 'nop' ; } else if ( pendingAction === 'delete' ) { throw new Error ( 'Operation ' + newAction + ' not supported as a DELETE operation is pending' ) ; //TODO: Limitation on all client SDKs } else { throw new Error ( 'Condense not supported when pending action is ' + pendingAction + ' and new action is ' + newAction ) ; } if ( isLocked ( pendingOperation ) ) { condenseAction = 'add' ; } return condenseAction ; }
Determines how to condense the new action into the pending operation
@returns 'nop' - if no action is needed
'remove' - if the pending operation should be removed
'modify' - if the pending action should be modified to be the new action
'add' - if a new operation should be added
Determines how to condense the new action into the pending operation