census-display.js (689B)
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 "use strict"; 5 6 const { 7 actions, 8 censusDisplays, 9 } = require("resource://devtools/client/memory/constants.js"); 10 const DEFAULT_CENSUS_DISPLAY = censusDisplays.coarseType; 11 12 const handlers = Object.create(null); 13 14 handlers[actions.SET_CENSUS_DISPLAY] = function (_, { display }) { 15 return display; 16 }; 17 18 module.exports = function (state = DEFAULT_CENSUS_DISPLAY, action) { 19 const handle = handlers[action.type]; 20 if (handle) { 21 return handle(state, action); 22 } 23 return state; 24 };