Takes a rewinddb reducer and turns it into a redux-compatible reducer.

@param {Function} reducer  (Collection, Event) => Changeset
@param {string}   [collectionName]
@param {Function} (Array<Object>, Action) => Array<Object>
973778
function reduxifyReducer (reducer, collectionName = null) {
  return (state = [], action) => {
    const collection = createReduxifyCollection(state, collectionName)
    const changeset = reducer(collection, action)

    // the changesets returned by the reduxify collections are just plain synchronous methods
    return changeset && changeset !== collection
      ? applyChangeset(state, changeset)
      : state
  }

  function applyChangeset (state, changeset) {
    if (typeof changeset !== 'function') {
      console.error('Reduxify changeset is a plain function. Instead got:', changeset)
      throw new Error('Reduxify changeset is a plain function.')
    }
    // the changesets returned by the reduxify collections are just plain synchronous methods
    return changeset(state)
  }
}
113485
public static <T> Reducer<PersistentList<T>,T> toPersistentListReversed() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(Seq.empty()), a -> Seq.of(a));
    }
347026
function sendAnyChanges() {
                // Get all changes after syncedRevision that was not performed by the client we're talkin' to.
                var changes = db.changes.filter(function (change) { return change.rev > syncedRevision && change.source !== conn.clientIdentity; });
                // Compact changes so that multiple changes on same object is merged into a single change.
                var reducedSet = reduceChanges(changes, conn.clientIdentity);
                // Convert the reduced set into an array again.
                var reducedArray = Object.keys(reducedSet).map(function (key) { return reducedSet[key]; });
                // Notice the current revision of the database. We want to send it to client so it knows what to ask for next time.
                var currentRevision = db.revision;

                conn.sendText(JSON.stringify({
                    type: "changes",
                    changes: reducedArray,
                    currentRevision: currentRevision,
                    partial: false // Tell client that these are the only changes we are aware of. Since our mem DB is syncronous, we got all changes in one chunk.
                }));

                syncedRevision = currentRevision; // Make sure we only send revisions coming after this revision next time and not resend the above changes over and over.
            }
369086
function initRepeaterActions () {
		var loadDelays = ['300', '600', '900', '1200'];

		var sort = function (data, sortProperty, sortDirection) {
			var sortedData = _.sortBy(data, function (item) {
				return item[sortProperty];
			});

			// sort direction
			if (sortDirection === 'desc') {
				sortedData = sortedData.reverse();
			}

			return sortedData;
		};

		function getSampleDataSet (options, callback) {
			var resp = {
				count: data.repeater.listData.length,
				items: [],
				page: options.pageIndex
			};

			// get start and end limits for JSON
			var i, l;
			resp.pages = Math.ceil(resp.count / (options.pageSize || 50));

			i = options.pageIndex * (options.pageSize || 50);
			l = i + (options.pageSize || 50);
			l = (l <= resp.count) ? l : resp.count;
			resp.start = i + 1;
			resp.end = l;

			// setup columns for list view
			resp.columns = [
				{
					label: 'Common Name',
					property: 'commonName',
					sortable: true
				},
				{
					label: 'Latin Name',
					property: 'latinName',
					sortable: true
				},
				{
					label: 'Appearance',
					property: 'appearance',
					sortable: true
				},
				{
					label: 'Sound',
					property: 'sound',
					sortable: true
				}
			];

			// add sample items to datasource
			for (i; i < l; i++) {
				// from data.js
				resp.items.push(data.repeater.listData[i]);
			}

			resp.items = sort(resp.items, options.sortProperty, options.sortDirection);

			// call and simulate latency
			setTimeout(function () {
				callback(resp);
			}, loadDelays[Math.floor(Math.random() * 4)]);

		}

		// initialize the repeater
		var repeaterActions = $('#myRepeaterActions');
		repeaterActions.repeater({
			list_noItemsHTML: '<span>foo</span>',
			list_highlightSortedColumn: true,
			list_selectable: 'multi',
			list_actions: {
				width: 37,
				items: [
					{
						name: 'edit',
						html: '<span class="glyphicon glyphicon-pencil"></span> Edit'
					},
					{
						name: 'copy',
						html: '<span class="glyphicon glyphicon-copy"></span> Copy'
					},
					{
						name: 'delete',
						html: '<span class="glyphicon glyphicon-trash"></span> Delete',
						clickAction: function (helpers, callback, e) {
							console.log('hey it worked');
							console.log(helpers);
							e.preventDefault();
							callback();
						}
					}
				]
			},
			// setup your custom datasource to handle data retrieval;
			// responsible for any paging, sorting, filtering, searching logic
			dataSource: getSampleDataSet
		});
	}
257700
function renameCounterpartyToIssuerInOrderChanges(orderChanges) {
  return _.mapValues(orderChanges, function(changes) {
    return _.map(changes, function(change) {
      return utils.renameCounterpartyToIssuerInOrder(change);
    });
  });
}
903464
function reducer(state = initialState, action) {
  switch (action.type) {
    case SET_TOKEN: {
      const token = action.payload;
      // const providers = null;
      // const oauth = {
      //     providers
      // }
      return {...state, token};
    }

    case SET_AUTHENTICATING: {
      const authenticating = action.payload;
      return {...state, authenticating};
    }

    case SET_ME: {
      const me = action.payload
      return {...state, me};
    }

    case REQUEST_INVALIDATE_TOKEN: {
      if (action.error) {
        return {...state, error: action.payload.error};
      }
      else {
        return {...state,  error:null };
      }
    }

    case REQUEST_OAUTH_PROVIDERS: {
      if (action.error) {
        return {...state, error: action.payload.error};
      }
      else {
        return {...state,  error:null };
      }
    }

    case SET_OAUTH_ENABLED: {
      const enabled = action.payload;
      const oauth = {
        ...state.oauth,
        enabled
      }
      return {...state, oauth};
    }

    case RECEIVE_OAUTH_PROVIDERS: {
      const providers = action.payload;
      const oauth = {
          ...state.oauth,
          providers
      }
      return {...state, oauth};
    }

    case RECEIVE_API_KEY: {
      const apiKey = action.payload;
      return {...state, apiKey};
    }

    case SHOW_LOGIN_OPTIONS: {
      const show = action.payload;
      const ui = {...state.ui};
      ui.showLoginOptions = show;
      return {...state, ui}
    }

    case SHOW_GIRDER_LOGIN: {
      const show = action.payload;
      const ui = {...state.ui};
      ui.girder = {show};
      return {...state, ui}
    }

    case SHOW_NERSC_LOGIN: {
      const show = action.payload;
      const ui = {...state.ui};
      ui.nersc = {show};
      return {...state, ui}
    }

    default:  {
      return state;
    }
  }
}
353777
public static <T> void notifyChanges(RecyclerView.Adapter<?> adapter,
            final List<T> oldList, final List<T> newList) {

        DiffUtil.calculateDiff(new DiffUtil.Callback() {
            @Override
            public int getOldListSize() {
                return oldList == null ? 0 : oldList.size();
            }

            @Override
            public int getNewListSize() {
                return newList == null ? 0 : newList.size();
            }

            @Override
            public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
                return oldList.get(oldItemPosition).equals(newList.get(newItemPosition));
            }

            @Override
            public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
                return areItemsTheSame(oldItemPosition, newItemPosition);
            }
        }).dispatchUpdatesTo(adapter);
    }
199021
public static <T> Reducer<PersistentList<T>,T> toPersistentList() {
        return Reducer.<PersistentList<T>,T> of(Seq.empty(), (final PersistentList<T> a) -> b -> b.plusAll(a), (final T x) -> Seq.of(x));

    }
210580
function createSAlertStore(reducer) {
        var state = void 0;
        var listeners = [];
        var getState = function getState() {
            return state;
        };
        var dispatch = function dispatch(action) {
            state = reducer(state, action);
            listeners.forEach(function (listener) {
                return listener();
            });
        };
        var subscribe = function subscribe(listener) {
            listeners.push(listener);
            return function () {
                listeners = listeners.filter(function (l) {
                    return l !== listener;
                });
            };
        };
        dispatch({});
        return {
            getState: getState, dispatch: dispatch, subscribe: subscribe
        };
    }
929516
function(event, model, collection, options) {
      if ((event === 'add' || event === 'remove') && collection !== this) return;
      if (event === 'destroy') this.remove(model, options);
      if (event === 'change') {
        var prevId = this.modelId(model.previousAttributes());
        var id = this.modelId(model.attributes);
        if (prevId !== id) {
          if (prevId != null) delete this._byId[prevId];
          if (id != null) this._byId[id] = model;
        }
      }
      this.trigger.apply(this, arguments);
    }
497050
function CollectionRepeatManager(options) {
    var self = this;
    this.dataSource = options.dataSource;
    this.element = options.element;
    this.scrollView = options.scrollView;

    this.isVertical = !!this.scrollView.options.scrollingY;
    this.renderedItems = {};
    this.dimensions = [];
    this.setCurrentIndex(0);

    //Override scrollview's render callback
    this.scrollView.__$callback = this.scrollView.__callback;
    this.scrollView.__callback = angular.bind(this, this.renderScroll);

    function getViewportSize() { return self.viewportSize; }
    //Set getters and setters to match whether this scrollview is vertical or not
    if (this.isVertical) {
      this.scrollView.options.getContentHeight = getViewportSize;

      this.scrollValue = function() {
        return this.scrollView.__scrollTop;
      };
      this.scrollMaxValue = function() {
        return this.scrollView.__maxScrollTop;
      };
      this.scrollSize = function() {
        return this.scrollView.__clientHeight;
      };
      this.secondaryScrollSize = function() {
        return this.scrollView.__clientWidth;
      };
      this.transformString = function(y, x) {
        return 'translate3d('+x+'px,'+y+'px,0)';
      };
      this.primaryDimension = function(dim) {
        return dim.height;
      };
      this.secondaryDimension = function(dim) {
        return dim.width;
      };
    } else {
      this.scrollView.options.getContentWidth = getViewportSize;

      this.scrollValue = function() {
        return this.scrollView.__scrollLeft;
      };
      this.scrollMaxValue = function() {
        return this.scrollView.__maxScrollLeft;
      };
      this.scrollSize = function() {
        return this.scrollView.__clientWidth;
      };
      this.secondaryScrollSize = function() {
        return this.scrollView.__clientHeight;
      };
      this.transformString = function(x, y) {
        return 'translate3d('+x+'px,'+y+'px,0)';
      };
      this.primaryDimension = function(dim) {
        return dim.width;
      };
      this.secondaryDimension = function(dim) {
        return dim.height;
      };
    }
  }
251939
function changedActiveItems(regionMapping) {
  if (defined(regionMapping._regionDetails)) {
    reviseLegendHelper(regionMapping);
    if (!regionMapping._loadingData) {
      if (
        defined(regionMapping._imageryLayer) ||
        defined(regionMapping._hadImageryAtLayerIndex)
      ) {
        redisplayRegions(regionMapping);
      }
      regionMapping._changed.raiseEvent(regionMapping);
    }
  } else {
    regionMapping._legendHelper = undefined;
    regionMapping._legendUrl = undefined;
  }
}
354734
public static Reducer create(String txt) {
        Context cx = Context.enter();
        try {
            return new Reducer(txt, cx);
        } finally {
            Context.exit();
        }
    }
951231
def collection(name, options=None, **kwargs):
    '''
    
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': False,
        'comment': '',
    }

    if options is None:
        options = {}

    if __salt__["solrcloud.collection_exists"](name, **kwargs):

        diff = {}

        current_options = __salt__["solrcloud.collection_get_options"](name, **kwargs)

        # Filter options that can be updated
        updatable_options = [
            "maxShardsPerNode",
            "replicationFactor",
            "autoAddReplicas",
            "collection.configName",
            "rule",
            "snitch"]

        options = [k for k in six.iteritems(options) if k in updatable_options]

        for key, value in options:
            if key not in current_options or current_options[key] != value:
                diff[key] = value

        if not diff:
            ret['result'] = True
            ret['comment'] = 'Collection options are in desired state'
            return ret

        else:

            if __opts__['test']:
                ret['comment'] = 'Collection options "{0}" will be changed.'.format(name)
                ret['result'] = None
            else:
                __salt__['solrcloud.collection_set_options'](name, diff, **kwargs)
                ret['comment'] = 'Parameters were updated for collection "{0}".'.format(name)
                ret['result'] = True

            ret['changes'] = {
                'old': salt.utils.json.dumps(current_options, sort_keys=True, indent=4, separators=(',', ': ')),
                'new': salt.utils.json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))
            }
            return ret

    else:

        new_changes = salt.utils.json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))
        if __opts__['test']:
            ret['comment'] = 'The collection "{0}" will be created.'.format(name)
            ret['result'] = None
        else:
            __salt__["solrcloud.collection_create"](name, options, **kwargs)
            ret['comment'] = 'The collection "{0}" has been created.'.format(name)
            ret['result'] = True

        ret['changes'] = {
            'old': None,
            'new': str('options=') + new_changes  # future lint: disable=blacklisted-function
        }

    return ret
752252
function createManager () {
  const INITIAL_STATE = {
    content: null,
    loading: true,
    currentPathname: null,
    nextPathname: null
  }

  const store = createStore(reducer)

  function reducer (state = INITIAL_STATE, action) {
    switch (action.type) {
      case 'CONTENT_LOADED':
        if (!action.asynchronously || action.pathname === state.nextPathname) {
          return {
            content: action.content,
            loading: false,
            currentPathname: action.pathname,
            nextPathname: null
          }
        } else {
          return state
        }
      case 'CONTENT_LOAD_STARTED':
        return {
          content: state.content,
          loading: true,
          currentPathname: state.pathname,
          nextPathname: action.pathname
        }
      default:
        return state
    }
  }

  const manager = {
    subscribe (callback) {
      return store.subscribe(callback)
    },
    getContent () {
      return store.getState().content
    },
    getCurrentPathname () {
      return store.getState().currentPathname
    },
    isLoading () {
      return store.getState().loading
    },
    isReady () {
      return !!store.getState().content
    },
    handleContentLoaded (pathname, content, { asynchronously }) {
      store.dispatch({ type: 'CONTENT_LOADED', pathname, content, asynchronously })
    },
    handleContentLoadStarted (pathname) {
      store.dispatch({ type: 'CONTENT_LOAD_STARTED', pathname })
    }
  }

  return manager
}
1247253
function reducer(props, map, key) {
  return Object.assign({}, map, {
    [key]: props[key],
  });
}
697547
function reducer (type, records) {
      return reduce(records, function (hash, record) {
        record = outputRecord.call(self, type, msgpack.decode(record))
        hash[record[primaryKey]] = record
        return hash
      }, {})
    }