UNPKG

jest-allure2-reporter

Version:
28 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.linksMap = linksMap; const utils_1 = require("../../../utils"); const keyedLink_1 = require("./keyedLink"); function linksMap(customizer) { const simplifiedCustomizer = simplifyLinksMap(customizer); const customizerKeys = Object.keys(simplifiedCustomizer); return async ({ value, ...context }) => { return (0, utils_1.thruMaybePromise)(value, (value) => { const links = (0, utils_1.groupBy)(value, 'type'); const keys = (0, utils_1.uniq)([...customizerKeys, ...Object.keys(links)]); const batches = keys.map((key) => { const keyedContext = { ...context, value: (0, utils_1.asMaybeArray)(links[key]), }; const keyedCustomizer = simplifiedCustomizer[key]; return keyedCustomizer ? keyedCustomizer(keyedContext) : keyedContext.value; }); return (0, utils_1.maybePromiseAll)(batches, (batches) => (0, utils_1.compactArray)(batches).flat()); }); }; } function simplifyLinksMap(customizer) { return (0, utils_1.compactObject)((0, utils_1.mapValues)(customizer, (value, key) => (0, keyedLink_1.keyedLink)(value, key))); } //# sourceMappingURL=linksMap.js.map