Support "replace" utility function
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- tooling
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.
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;
- Lingua principale
- TypeScript
- Stelle
- 759
- Fork
- 66
- Merge medio
- 5g 10h
- PR unite (30g)
- 7
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.
Altre issue di microsoft/node-jsonc-parser
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
microsoft/node-jsonc-parser#125 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
microsoft/node-jsonc-parser#105 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
microsoft/node-jsonc-parser#103 · 2 commenti · 8 reazioni ·
-
Provide usage examples Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
microsoft/node-jsonc-parser#97 · 3 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
microsoft/node-jsonc-parser#95 · 1 reazione ·
Tutte le issue di microsoft/node-jsonc-parser
Issue simili
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100