Skip to content

Align keys/values in objects? #155

Open

Description

@mcmire

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions