How to use the immutable.OrderedSet function in immutable

To help you get started, we’ve selected a few immutable 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 keyz / repo.cat / src / reducers / stats.js View on Github external
*/

import {
  Map as iMap,
  OrderedSet as iOrderedSet,
} from 'immutable';

import {
  REPO_LANG,
  HN_RAW_COUNT,
} from '../constants';

const initialDataState = iMap({
  top: iOrderedSet(),
  show: iOrderedSet(),
  new: iOrderedSet(),
  rawCount: iMap({
    top: 0,
    show: 0,
    new: 0,
  }),
});

const langsReducer = (state = initialDataState, action) => {
  switch (action.type) {
    case REPO_LANG: {
      const { category, data } = action.payload;

      const langs = Object.keys(data); // @TODO keep the order of the set

      return state.updateIn(
        [ category ],
github inveniosoftware-contrib / ng2-json-editor / src / shared / services / keys-store.service.spec.ts View on Github external
}
          }
        }
      }
    };
    MockJsonSchemaService.schemaToReturn = schema.properties.child;
    // build initial keys map
    const json = fromJS({
      child: {
        grandChild1: 'value'
      }
    });
    service.buildKeysMap(json, schema);
    const expectedKeysMap = {
      '': OrderedSet(['child']),
      '/child': OrderedSet(['grandChild2'])
    };
    // new json after set
    const newJson = fromJS({
      child: {
        grandChild2: 'value',
      }
    });
    service.syncKeysForPath(['child'], newJson);
    expect(service.keysMap).toEqual(expectedKeysMap);
  });
github ShieldBattery / ShieldBattery / server / lib / wsapi / whispers.js View on Github external
async _handleNewUser(user) {
    // Publish 'userActive' event to all users that have a session opened with the new user, if any
    if (this.sessionUsers.has(user.name)) {
      for (const u of this.sessionUsers.get(user.name).values()) {
        this._publishTo(user.name, u, { action: 'userActive', target: user.name })
      }
    }

    const whisperSessions = await getWhisperSessionsForUser(user.session.userId)
    if (!user.sockets.size) {
      // The user disconnected while we were waiting for their whisper sessions
      return
    }

    this.userSessions = this.userSessions.set(user.name, new OrderedSet(whisperSessions))
    for (const target of whisperSessions) {
      // Add the new user to all of the sessions they have opened
      this.sessionUsers = this.sessionUsers.update(target, new Set(), s => s.add(user.name))
      this._subscribeUserToWhisperSession(user, target)
    }

    user.subscribe(`${user.getPath()}/whispers`, () => ({ type: 'whispersReady' }))
  }
github iamdjones / sublime-text-browser-sync / browser-sync / node_modules / browser-sync-ui / lib / plugins / history / history.js View on Github external
module.exports.init = function (ui, bs) {

    var validUrls = Immutable.OrderedSet();

    var methods = {
        /**
         * Send the url list to UI
         * @param urls
         */
        sendUpdatedUrls: function (urls) {
            ui.socket.emit("ui:history:update", decorateUrls(urls));
        },
        /**
         * Only send to UI if list changed
         * @param current
         * @param temp
         */
        sendUpdatedIfChanged: function (current, temp) {
            if (!Immutable.is(current, temp)) {
github peerplays-network / peerplays-core-gui / dl / src / stores / to_rm / MarketsStore.js View on Github external
constructor() {
    this.markets = Immutable.Map();
    this.asset_symbol_to_id = {};
    this.pendingOrders = Immutable.Map();
    this.activeMarketLimits = Immutable.Map();
    this.activeMarketCalls = Immutable.Map();
    this.activeMarketSettles = Immutable.OrderedSet();
    this.activeMarketHistory = Immutable.OrderedSet();
    this.bids = [];
    this.asks = [];
    this.calls = [];
    this.flat_bids = [];
    this.flat_asks = [];
    this.flat_calls = [];
    this.totalBids = 0;
    this.totalCalls = 0;
    this.priceData = [];
    this.volumeData = [];
    this.pendingCreateLimitOrders = [];
    this.activeMarket = null;
    this.quoteAsset = null;
    this.pendingCounter = 0;
    this.buckets = [15,60,300,3600,86400];
github Graylog2 / graylog2-server / graylog2-web-interface / src / components / common / TypeAheadDataFilter.jsx View on Github external
constructor(props) {
    super(props);
    const { filterBy } = this.props;
    this.state = {
      filterText: '',
      filters: Immutable.OrderedSet(),
      filterByKey: `${filterBy}s`,
    };
  }
github markfinger / unfort / cyclic_dependency_graph / graph.js View on Github external
constructor(resolver, options) {
        this.start = new rxjs_1.Subject();
        this.complete = new rxjs_1.Subject();
        this.error = new rxjs_1.Subject();
        this.nodes = imm.Map();
        this.entryPoints = imm.OrderedSet();
        this._pendingJobs = [];
        this._hasSignalledStart = false;
        this._prunedNodes = new Set();
        this.resolver = resolver;
        if (options && options.initialState) {
            this.nodes = (options && options.initialState);
        }
    }
    /**
github CenterForOpenScience / ember-osf-web / lib / registries / addon / components / registries-discover-search / x-sidebar / component.ts View on Github external
clearFilters(this: SideBar) {
        this.analytics.track('button', 'click', 'Discover - Clear Filters');
        this.onSearchOptionsUpdated(this.searchOptions.set('filters', OrderedSet()));
    }
}
github Graylog2 / graylog2-server / graylog2-web-interface / src / views / components / widgets / MessageList.jsx View on Github external
_columnStyle = (fieldName) => {
    const { fields } = this.props;
    const selectedFields = Immutable.OrderedSet(fields);
    if (fieldName.toLowerCase() === 'source' && selectedFields.size > 1) {
      return { width: 180 };
    }
    return {};
  };
github TrustedPlus / esign / app / reducer / documents.ts View on Github external
return documents = new DefaultReducerState();

    case REMOVE_DOCUMENTS:
      return documents = new DefaultReducerState();

    case ARHIVE_DOCUMENTS:
      return documents = new DefaultReducerState();

    case SELECT_DOCUMENT:
      return documents.update("selected", (selected) => selected.has(payload.uid)
        ? selected.remove(payload.uid)
        : selected.add(payload.uid),
      );

    case UNSELECT_ALL_DOCUMENTS:
      return documents.set("selected", new OrderedSet([]));

  }

  return documents;
};