-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path should be an array #44
Comments
Since using dot notation is the most popular way of describing objects, I'd rather return an escaped path like |
@kevva And if you return "escaped" dots, how should consumer process the string? Will you include a function for unescaping too? |
Well, it's how you write it when accessing props on an object for example.
You can access the property by using https://github.com/sindresorhus/dot-prop. |
@kevva so would I have to install that package too to use this one? This is ridiculous |
No, it's just a suggestion. Using your proposed solution, you'd still have to convert the array to something before you could access the property of the object as well so I don't see what the tradeoff is here. Also, the |
@kevva {
'a.b':1,
'a': { 'b': 2 },
} Changing 1 or 2 in case of array would produce determined Also, considering, that implementation relies on dotted path in The point is, you cannot use dot as an object-tree path separator since it's a valid character for property names. That's the reason popular utility libs use primarily array as object-tree path, string only as a convenience option. Look at |
I'm not saying that I disregard your solution, I just prefer the escaped one. It's non-breaking (most likely) and is directly compatible with
This is a non-issue IMO. It's easy to check for in code providing that the path is escaped. But yeah, I'm not opposed to returning |
I think I'll start working on PR in spare time |
Path arg should be an array, since prop name could contain
.
The text was updated successfully, but these errors were encountered: