UNPKG

@ournet/news-data

Version:
37 lines (36 loc) 958 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function sortEntitiesByIds(ids, entities) { const list = []; for (const id of ids) { const entity = entities.find(item => item.id === id); if (entity) { list.push(entity); } } return list; } exports.sortEntitiesByIds = sortEntitiesByIds; function buildDateRangeKey(params) { let rangeKey; if (params.maxDate && params.minDate) { rangeKey = { operation: 'BETWEEN', value: [params.minDate, params.maxDate] }; } else if (params.maxDate) { rangeKey = { operation: '<', value: params.maxDate }; } else if (params.minDate) { rangeKey = { operation: '>', value: params.minDate }; } return rangeKey; } exports.buildDateRangeKey = buildDateRangeKey;