Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 5x 38x 494x 20x 20x 20x 72x 14x 13x 20x 11x 20x | import { queryToObject } from '~/lib/utils/url_utility'; import { TOKENS } from './constants'; export const generateUserPaths = (paths, id) => { return Object.fromEntries( Object.entries(paths).map(([action, genericPath]) => { return [action, genericPath.replace('id', id)]; }), ); }; /** * @typedef {{type: string, value: {data: string, operator: string}}} Token */ /** * Initialize token values based on the URL parameters * @param {string} query - document.location.searchd * * @returns {{tokens: Array<string|Token>, sort: string}} */ export function initializeValuesFromQuery(query = document.location.search) { const tokens = []; const { filter, search_query: searchQuery, sort } = queryToObject(query); if (filter) { const token = TOKENS.find(({ options }) => options.some(({ value }) => value === filter)); if (token) { tokens.push({ type: token.type, value: { data: filter, operator: token.operators[0].value, }, }); } } if (searchQuery) { tokens.push(searchQuery); } return { tokens, sort }; } |