microsoft / microsoft/node-jsonc-parser
Support "replace" utility function
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 759
- Fork
- 66
- Merge medio
- 5g 10h
- PR unite (30g)
- 7
Descrizione
Similar to the "modify" function, but allowing the key to be changed too.
The two use cases I have in mind for this is:
- Renaming a key in-place while retaining the existing value
- Replacing an existing key/value with new key/value in the same place
Of course, the existing modify function could be overloaded to support this, but I suggest a new function because:
- It's not valid to supply the root for a replace
- The meaning of undefined value param changes
Example of how this would look if "replace" is implemented:
/**
* Computes the edit operations needed to replace a key/value in the JSON document.
*
* @param documentText The input text
* @param path The path of the value to change. The path represents either to a property or an array item.
* If the path points to an non-existing property or item, an error will be thrown.
* @param key The new key name for the specified property or item.
* @param value The new value for the specified property or item. If the value is undefined,
* the existing value will be retained.
* @param options Options
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
* To apply the edit operations to the input, use {@linkcode applyEdits}.
*/
export function replace(text: string, path: JSONPath, key: string, value: any, options: ModificationOptions): EditResult;
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando la funzione esistente "modify" e la gestione di percorsi, chiavi e valori undefined. Definisci il comportamento di replace per rinominare una chiave, sostituire una chiave/valore, rifiutare il percorso radice e mantenere il valore quando è undefined; il lavoro è completato quando la funzione esportata produce le operazioni di modifica documentate per questi casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100