add key path param - #1
Draft
maa-dar wants to merge 7 commits into
Draft
Conversation
add key path to parameters sent to compare and replacer as this info is sometimes very crutial
ljharb
requested changes
Apr 13, 2023
ljharb
left a comment
Owner
There was a problem hiding this comment.
Can you elaborate on the use case here?
Either way it'd need documentation and tests.
| var seen = []; | ||
| return (function stringify(parent, key, node, level) { | ||
| var indent = space ? '\n' + new Array(level + 1).join(space) : ''; | ||
| return (function stringify(parent, key, node, path = []) { |
Owner
There was a problem hiding this comment.
using this syntax would be a breaking change.
Author
There was a problem hiding this comment.
Suggested change
| return (function stringify(parent, key, node, path = []) { | |
| return (function stringify(parent, key, node, path = []) { | |
| path = typeof(path) === 'number' ? new Array(path) : path; |
Owner
There was a problem hiding this comment.
the breaking syntax is default parameters - = in a function signature.
Author
There was a problem hiding this comment.
cool then
Suggested change
| return (function stringify(parent, key, node, path = []) { | |
| return (function stringify(parent, key, node, path = []) { | |
| path = typeof(path) === 'number' ? new Array(path) : (path == null ? [] : path); |
Owner
There was a problem hiding this comment.
again, it's the path = [] in the signature that can't work.
ljharb
marked this pull request as draft
April 13, 2023 05:29
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add key path to parameters sent to compare and replacer as this info is sometimes very crutial.
Why?
Often one would like to customize the printing of json based on where the json is in the tree like for example take:
so here the family of the asset i want it before the name while in the user i want the family name to be before. (Note this is a theoratical example just to better explain my point)