tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

runtimes-state-helper.js (1242B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 function getCurrentRuntime(runtimesState) {
      8  const selectedRuntimeId = runtimesState.selectedRuntimeId;
      9  return findRuntimeById(selectedRuntimeId, runtimesState);
     10 }
     11 exports.getCurrentRuntime = getCurrentRuntime;
     12 
     13 function getCurrentClient(runtimesState) {
     14  const runtimeDetails = getCurrentRuntimeDetails(runtimesState);
     15  return runtimeDetails ? runtimeDetails.clientWrapper : null;
     16 }
     17 exports.getCurrentClient = getCurrentClient;
     18 
     19 function findRuntimeById(id, runtimesState) {
     20  return getAllRuntimes(runtimesState).find(r => r.id === id);
     21 }
     22 exports.findRuntimeById = findRuntimeById;
     23 
     24 function getAllRuntimes(runtimesState) {
     25  return [
     26    ...runtimesState.networkRuntimes,
     27    ...runtimesState.thisFirefoxRuntimes,
     28    ...runtimesState.usbRuntimes,
     29  ];
     30 }
     31 exports.getAllRuntimes = getAllRuntimes;
     32 
     33 function getCurrentRuntimeDetails(runtimesState) {
     34  const runtime = getCurrentRuntime(runtimesState);
     35  return runtime ? runtime.runtimeDetails : null;
     36 }
     37 exports.getCurrentRuntimeDetails = getCurrentRuntimeDetails;