search.js (775B)
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 getOngoingSearch(state) { 8 return state.search.ongoingSearch; 9 } 10 11 function getSearchStatus(state) { 12 return state.search.status; 13 } 14 15 function getSearchResultCount(state) { 16 const { results } = state.search; 17 return ( 18 (results.length !== 0 19 ? results.reduce((total, current) => total + current.results.length, 0) 20 : 0) + "" 21 ); 22 } 23 24 function getSearchResourceCount(state) { 25 return state.search.results.length + ""; 26 } 27 28 module.exports = { 29 getOngoingSearch, 30 getSearchStatus, 31 getSearchResultCount, 32 getSearchResourceCount, 33 };