Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
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 ],
}
}
}
}
};
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);
});
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' }))
}
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)) {
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];
constructor(props) {
super(props);
const { filterBy } = this.props;
this.state = {
filterText: '',
filters: Immutable.OrderedSet(),
filterByKey: `${filterBy}s`,
};
}
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);
}
}
/**
clearFilters(this: SideBar) {
this.analytics.track('button', 'click', 'Discover - Clear Filters');
this.onSearchOptionsUpdated(this.searchOptions.set('filters', OrderedSet()));
}
}
_columnStyle = (fieldName) => {
const { fields } = this.props;
const selectedFields = Immutable.OrderedSet(fields);
if (fieldName.toLowerCase() === 'source' && selectedFields.size > 1) {
return { width: 180 };
}
return {};
};
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;
};