I firmly believe in free software. The application I'm making here have capabilities that I've not seen in any system. It presents itself as an opportunity to collaborate on a tool that serves the people rather than corporations. Whose incentives are to help people rather, not make the most money. And whose terms ensure that these freedoms and incentives cannot be taken back or subverted. I license this software under the AGPL.
26 lines
792 B
TypeScript
26 lines
792 B
TypeScript
/*
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
import type { LocationQueryValue } from 'vue-router';
|
|
import type { Id } from '~/shared/types/common';
|
|
|
|
export function queryToString(item?: null | LocationQueryValue | LocationQueryValue[]) {
|
|
if (item === null)
|
|
return "";
|
|
if (item instanceof Array)
|
|
return queryToString(item[0])
|
|
return item;
|
|
}
|
|
|
|
export function queryToNumber(item?: null | LocationQueryValue | LocationQueryValue[]) {
|
|
if (item === null || item === undefined)
|
|
return undefined;
|
|
if (item instanceof Array)
|
|
return queryToNumber(item[0])
|
|
return Number.parseInt(item, 10);
|
|
}
|
|
|
|
export function idMap<T extends { id: Id }>(entities: T[]) {
|
|
return new Map(entities.map(entity => [entity.id, entity]));
|
|
}
|