Support "replace" utility function
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- tooling
调研方向
首先检查现有的 "modify" 函数,以及它对路径、键和 undefined 值的处理方式。定义 replace 在重命名键、替换键/值、拒绝根路径以及值为 undefined 时保留该值这些情况下的行为;当导出的函数针对这些情况生成文档中记录的编辑操作时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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;
- 主要语言
- TypeScript
- 星标
- 759
- 派生
- 66
- 平均合并
- 5 天 10 小时
- 30 天内合并 PR
- 7
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/node-jsonc-parser 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
microsoft/node-jsonc-parser#125 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
microsoft/node-jsonc-parser#105 ·
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/node-jsonc-parser#103 · 2 条评论 · 8 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 48/100
microsoft/node-jsonc-parser#97 · 2 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
microsoft/node-jsonc-parser#95 · 1 个 reaction ·
查看 microsoft/node-jsonc-parser 的全部 Issue
相似的 Issue
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
Browser Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 85/100
getsentry/sentry-javascript#24577 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
agilepathway/label-checker#640 ·
-
Plugin stuck at "loading" on DSH 0.1.6-alpha.2 — turnTail list slot registration missing options.id 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 68/100
chrisparsons83/flexspotff#153 ·