mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 12:03:25 -04:00
(refactor) rename and move entriesWithKeys and getWithKey utilities to ~~/shared/utils
This commit is contained in:
parent
9425d88df1
commit
9142a99b22
@ -16,7 +16,7 @@ const config = useConfig();
|
||||
const nounsData = await loadNounsData();
|
||||
|
||||
const nouns = computed((): Noun[] => {
|
||||
return withKey(nounsData.classes ?? {})
|
||||
return entriesWithKeys(nounsData.classes ?? {})
|
||||
.map((nounClass): NounClassInstance => ({ classKey: nounClass.key, stems: props.stemValues }))
|
||||
.map((classInstance, i): NounRawWithLoadedWords => ({
|
||||
id: `template-${i}`,
|
||||
|
@ -7,7 +7,7 @@ const nounsData = await loadNounsData();
|
||||
<template>
|
||||
<ul v-if="nounsData.groups" class="list-group mt-4">
|
||||
<li
|
||||
v-for="nounConventionGroup of withKey(nounsData.groups)"
|
||||
v-for="nounConventionGroup of entriesWithKeys(nounsData.groups)"
|
||||
:key="nounConventionGroup.key"
|
||||
class="list-group-item"
|
||||
>
|
||||
|
@ -11,7 +11,7 @@ if (nounsData === undefined) {
|
||||
throw new Error('nounsData is undefined');
|
||||
}
|
||||
const visibleNounConventions = computed(() => {
|
||||
return withKey(nounsData.conventions ?? {}).filter((nounConvention) => {
|
||||
return entriesWithKeys(nounsData.conventions ?? {}).filter((nounConvention) => {
|
||||
return props.nounConventionGroup.conventions.includes(nounConvention.key);
|
||||
});
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ const id = useId();
|
||||
<template>
|
||||
<h5><T>nouns.submit.regular.stems.header</T></h5>
|
||||
<p><T>nouns.submit.regular.stems.description</T></p>
|
||||
<template v-for="stem of withKey(nounsData.stems ?? {})" :key="stem.key">
|
||||
<template v-for="stem of entriesWithKeys(nounsData.stems ?? {})" :key="stem.key">
|
||||
<label :for="`${id}-stem-${stem.key}`">{{ stem.name }}</label>
|
||||
<input
|
||||
:id="`${id}-stem-${stem.key}`"
|
||||
|
@ -25,7 +25,7 @@ const findNounConvention = async (path: string, config: Config) => {
|
||||
|
||||
const nounsData = await loadNounsData();
|
||||
|
||||
return withKey(nounsData.conventions ?? {})
|
||||
return entriesWithKeys(nounsData.conventions ?? {})
|
||||
.find((nounConvention) => nounConvention.key === path);
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@ import type {
|
||||
Gender,
|
||||
Numerus,
|
||||
} from '~~/shared/nouns.ts';
|
||||
import type { WithKey } from '~~/shared/utils/entriesWithKeys.ts';
|
||||
|
||||
export class PronounExample {
|
||||
singular: Example;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { WithKey } from '~/utils/withKey.ts';
|
||||
import type { WithKey } from '~~/shared/utils/entriesWithKeys.ts';
|
||||
|
||||
export default <T>(record: Record<string, T> | undefined, key: string | undefined): WithKey<T> | undefined => {
|
||||
if (key === undefined || record?.[key] === undefined) {
|
Loading…
x
Reference in New Issue
Block a user