expressions.js (890B)
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 import { createSelector } from "devtools/client/shared/vendor/reselect"; 6 7 const getExpressionsWrapper = state => state.expressions; 8 9 export const getExpressions = createSelector( 10 getExpressionsWrapper, 11 expressions => expressions.expressions 12 ); 13 14 const getAutocompleteMatches = createSelector( 15 getExpressionsWrapper, 16 expressions => expressions.autocompleteMatches 17 ); 18 19 export function getExpression(state, input) { 20 return getExpressions(state).find(exp => exp.input == input); 21 } 22 23 export function getAutocompleteMatchset(state) { 24 const input = state.expressions.currentAutocompleteInput; 25 if (!input) { 26 return null; 27 } 28 return getAutocompleteMatches(state)[input]; 29 }