Skip to content
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

Align keys/values in objects? #155

Open
mcmire opened this issue Jun 29, 2022 · 0 comments
Open

Align keys/values in objects? #155

mcmire opened this issue Jun 29, 2022 · 0 comments

Comments

@mcmire
Copy link
Collaborator

mcmire commented Jun 29, 2022

I just stumbled upon a Node library called string.ify that looks fairly interesting. It aims to format objects such that keys and values are aligned as much as possible. So it turns something like this:

{
  obj: [
    {
      someLongPropertyName: 1,
      propertyName: 2,
      anotherProp: 4,
      moreProps: 5
    },
    {
      propertyName: {
        someVeryLongPropertyName: true,
        qux: 6,
        zap: "lol"
      }
    }
  ]
}

into this:

{ obj: [ { someLongPropertyName: 1,
                   propertyName: 2,
                    anotherProp: 4,
                      moreProps: 5  },
         { propertyName: { someVeryLongPropertyName:  true,
                                                qux:  6,
                                                zap: "lol"  } } ] }

This looks highly unconventional, and requires a wide terminal width / screen to view properly. However, it makes scanning a giant data structure very easy:

It might be worth it to experiment with how this would look in a diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant