<commit_before>var Bacon = require("baconjs");
var Dispatcher = require("bacon-dispatcher");
var d = new Dispatcher();

var appState = {};

appState.initialState = {
  "connectionState": "offline"
};

var onSetConnectionState = function(currentState, connectionState){
  currentState.connectionState = connectionState;
  return currentState;
};

var onSetTeamUrl = function(currentState, teamUrl){
  currentState.teamUrl = teamUrl;
  return currentState;
};

appState.setConnectionState = function(connectionState){
  d.push("setConnectionState", connectionState);
};

appState.setTeamUrl = function(teamUrl){
  d.push("setTeamUrl", teamUrl);
};

appState.initStream = function(){
  var setConnectionStateStream = d.stream("setConnectionState");
  var setTeamUrlStream = d.stream("setTeamUrl");

  var fullStream = Bacon.update(
    appState.initialState,
    [setConnectionStateStream], onSetConnectionState,
    [setTeamUrlStream], onSetTeamUrl
  );
  return fullStream;
};

module.exports = appState;<commit_msg>add capability to add teams and set a team as selected<commit_after>var Bacon = require("baconjs");
var Dispatcher = require("bacon-dispatcher");
var d = new Dispatcher();

var appState = {};

appState.initialState = {
  connectionState: "offline",
  teams: {},
  selectedTeam: ""
};

var onSetConnectionState = function(currentState, connectionState){
  currentState.connectionState = connectionState;
  return currentState;
};

var onAddTeam = function(currentState, team){
  currentState.teams[team.name] = team;
  var isFirstTeam = (Object.keys(currentState.teams).length === 1);
  var noneSelected = (currentState.selectedTeam === "");
  if (isFirstTeam && noneSelected) {
    appState.selectTeam(team.name);
  }
  return currentState;
};

var onSelectTeam = function(currentState, teamName){
  currentState.selectedTeam = teamName;
  return currentState;
}

appState.setConnectionState = function(connectionState){
  d.push("setConnectionState", connectionState);
};

appState.addTeam = function(team){
  d.push("addTeam", team);
};

appState.selectTeam = function(teamName){
  d.push("selectTeam", teamName);
};

appState.initStream = function(){
  var setConnectionStateStream = d.stream("setConnectionState");
  var addTeamStream = d.stream("addTeam");
  var selectTeamStream = d.stream("selectTeam");

  var fullStream = Bacon.update(
    appState.initialState,
    [setConnectionStateStream], onSetConnectionState,
    [addTeamStream], onAddTeam,
    [selectTeamStream], onSelectTeam
  );
  return fullStream;
};

module.exports = appState;
{'fraction_non_alphanumeric': 0.12587685113016367, 'fraction_numerical': 0.0003897116134060795, 'mean_word_length': 5.719895287958115, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5291384', 'n_tokens_mistral': 773, 'n_tokens_neox': 762, 'n_words': 157}