formatchange
Version:
Utility that monitors named CSS media-query breakpoints and triggers event callbacks when a media-format change occurs.
27 lines (26 loc) • 868 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeGroups = void 0;
/**
* Esoteric helper that maps a complex `GroupConfig` config object
* into a `FormatMonitorGroupConfig`
*
* @see https://github.com/maranomynet/formatchange/tree/v2#makegroups-helper
*/
var makeGroups = function (groupConfig) {
var mediaGroups = {};
Object.entries(groupConfig).forEach(function (_a) {
var format = _a[0], formatConfig = _a[1];
var grp = formatConfig.group;
if (grp) {
var groups = Array.isArray(grp) ? grp : [grp];
groups.forEach(function (group) {
var grpCfg = mediaGroups[group] || {};
mediaGroups[group] = grpCfg;
grpCfg[format] = true;
});
}
});
return mediaGroups;
};
exports.makeGroups = makeGroups;