UNPKG

@x-ray/core

Version:
67 lines (56 loc) 1.62 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.getList = void 0; var _funcom = require("funcom"); var _iterama = require("iterama"); var _tsfn = require("tsfn"); const getList = options => { const shortKeys = (0, _funcom.pipe)((0, _iterama.map)(value => value.name), _iterama.toArray)(options.results.values()); const items = (0, _funcom.pipe)((0, _iterama.reduce)((acc, fileResults) => { for (const [exampleId, exampleResult] of fileResults.results) { const key = `${fileResults.name}::${exampleId}`; switch (exampleResult.type) { case 'NEW': { acc[key] = { type: 'NEW', width: exampleResult.width, height: exampleResult.height }; break; } case 'DIFF': { acc[key] = { type: 'DIFF', width: exampleResult.width, height: exampleResult.height, origWidth: exampleResult.origWidth, origHeight: exampleResult.origHeight }; break; } case 'DELETED': { acc[key] = { type: 'DELETED', width: exampleResult.width, height: exampleResult.height }; break; } } } return acc; }, {}), _iterama.toValue)(options.results.values()); if ((0, _tsfn.isUndefined)(items)) { throw new Error('server: no results'); } return { type: options.encoding, files: shortKeys, items }; }; exports.getList = getList;