-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: add support for Arrays #12
Comments
Why? Do you have any actual use-cases for this? This module is about sorting the keys of objects. Feels weird to support array as an input, even if it's an array of objects. |
If you know you're dealing with an array of objects you can do the following: const sorted = arrayOfObjects.map(item => sortKeys(item, {deep: true})); |
This would improve the experience for This would be a useful addition for any number of libraries that need a consistent scan order of an arbitrary object (i.e. I don't know if the user is giving me an array, or a plain obj). Additionally, it is not trivial to wrap this for Array's as @coreyfarrell suggests, as you would miss out on circular reference when deep-sorting |
Right now you can't pass an Array to
sortKeys(...)
- ideally we should be able to pass an Array (e.g. an Array of objects) or a plain Object to the method exported.Related: #10
The text was updated successfully, but these errors were encountered: