Feature Request: Add path notation.
See original GitHub issueWithout a path notation it is not actually possible to edit an update spec object with an update spec since it cannot distinguish a key from an operation. Adding path notation also has the advantage that it would also provide dot notation as requested in #17.
The method to disambiguate unusual keys is to use the normal bracket notation (with escaping for at least the close bracket) optionally with quote support. With this the operation doesn’t actually need any special handling since it must always be the last element in any path.
This then gives the following:
const newData = updatePath(myData, {
"x.y.z.$set": 7,
"a.b.$push": [9]
});
const newCollection = updatePath(collection, { "2.a.$splice": [[1, 1, 13, 14]]});
const newPathed = updatePath(pathed, {
"[path.with.dots][next.part].$set": true, // sets pathed["path.with.dots"]["next.part"]
"$set.$merge.$push": [1], // pushes to pathed.$set.$merge
"[bracket\\]prop].$set": "eugh escapes", // sets pathed["bracket]prop"]
});
As an extension if double quotes are allowed in the brackets then automatic escaping of strings can be managed through JSON.stringify()
. Consider:
const newData = updatePath(myData, {
[`[${JSON.stringify(computedName)}].$set`]: "supports primitive values",
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
[Feature Request] support for path variables #519 - GitHub
Would be nice to have a support for path variables: /users/{userId}/numbers Currently we can only use an environment variable in that case.
Read more >3 ways to manage software feature request - Amoeboids
The best way to keep feature requests in one place is to set up a centralized repository. Whether a feature request is received...
Read more >How to Submit a Feature Request - Pathable
Select Feature Request Forum in the upper-right corner of the page · Select "New Post" button on the right-side of the page ·...
Read more >Submit a feature request for Solarwinds Products
This article describes how to submit a feature request to SolarWinds. Feature requests and votes by you and other SolarWinds users help ...
Read more >[Absolute or Relative path] `Default location for new notes ...
Currently, create new notes from relative path is very problematic as noted in a related feature request Obsidian has trouble creating new notes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That seems out of scope to this library but you can use the flatulence library with this to accomplish that
I should say that it’s possible that the memoisation would effectively offset the parsing overhead (from all but the first run). The problem is reconstructing a hierarchical update (as I think you’re referring to re:
reduce
). If efficiency is a concern, it’s simplest just to represent your update hierarchically in which case the trivial recursive implementation is optimal at using the fewest number of shallow copies.