[mf2 JS api] Why this `selectKey` design?
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 30/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- javascript, typescript
- Domaine
- api
Piste de recherche
Start with the selectKey implementation for Number and trace how repeated calls produce the priority-ordered matches in the MF2 examples. Compare the proposed array and generator alternatives, then define the API behavior and completion criteria before making a change.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Let me start by saying that the way selectKey works is quite confusing. After reading the selectKey implementation for Number, I to took me a while for me to figure out how both these examples return x:
.local $n = {1 :number}
.match $n
one {{ a }}
1 {{ x }}
one {{ c }}
* {{}}
.local $n = {1 :number}
.local $m = {2 :number}
.match $n $m
1 3 {{ a }}
one 2 {{ x }}
* * {{}}
Once it clicked that the way it works is by calling .selectKey multiple times, each time removing the value that "won" the previous time if it didn't lead to a success.
This means that, if I need to normalize my value to check if it's in the set (and for number it's trivial, it's just a String(num), but for other types it can be much more complex), then:
- the first time I have to normalize it for the "best way"
- the second time I have to normalize it for the "best way" (to discover it's not in the set anymore) and "second best way"
- the third time I have to normalize it for the "best way" (to discover it's not in the set anymore), "second best way" (to discover it's not in the set anymore), and "third best way"
- ... and so on
Why doesn't .selectKey return an array instead, so that it already returns the various matches in priority order and I don't have to re-compute all the previous steps at every call?
If the reason is "because maybe the first match matches, so computing the second and third one is a waste", could it instead return a generator? yield bestMatch; yield secondBestMatch; ...
- Langage dominant
- TypeScript
- Étoiles
- 1.8k
- Forks
- 160
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de messageformat/messageformat
-
help wanted
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
messageformat/messageformat#462 · 4 commentaires ·
-
Xliff: use a real namespaceOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
messageformat/messageformat#455 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 45/100
messageformat/messageformat#434 ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
messageformat/messageformat#406 · 1 commentaire ·
-
ES module versionOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
messageformat/messageformat#405 · 7 commentaires · 9 réactions ·
Toutes les issues de messageformat/messageformat
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
microsoft/vscode-livepreview#876 ·
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
JustJarethB/invoicer#54 ·
-
ICP 1.2.0 shows a scheduled task's interval in milliseconds under the label "Interval (In seconds)"OuverteNeeds Triage Type/Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
wso2/product-integrator#2585 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: Telemundo West sdOuvertecheck:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
design
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
MTES-MCT/monitor-field#119 ·
Les mainteneurs répondent en général sous 1 jour