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

stringify cson with no indent #37

Merged
merged 3 commits into from
May 12, 2015
Merged

stringify cson with no indent #37

merged 3 commits into from
May 12, 2015

Conversation

charlierudolph
Copy link

serializedValue = visitNode value, bracesRequired: !indent
if indent
serializedValue = if isObject value
"\n#{ indentLines serializedValue }"
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here doesn't seem to align

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats the proper place for the else. Its matching if is only two lines above, not three

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does – lines 96 and 98 go together, not 95 and 98.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. Sorry. Could you maybe change this to something like this:

        serializedValue =
          if isObject value
            "\n#{ indentLines serializedValue }"
          else
            " #{ serializedValue }"

That way it's a bit easier to scan the left side of the code and grok the structure. Partially a question of personal taste but I'm fairly certain that matches our (informal) code style.

@jkrems
Copy link
Contributor

jkrems commented May 6, 2015

Wow, that was quick! One small indentation thing but other than that LGTM.

serializedValue
items = arr.map (value) -> visitNode value, bracesRequired: true

serializedItems = if indent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - I'd prefer if we keep if and else tokens on one height.

@charlierudolph
Copy link
Author

@jkrems all comments addressed

jkrems added a commit that referenced this pull request May 12, 2015
@jkrems jkrems merged commit bc81dcd into groupon:master May 12, 2015
@charlierudolph charlierudolph deleted the cr-minifiedCson branch May 12, 2015 20:39
@jkrems
Copy link
Contributor

jkrems commented May 12, 2015

v1.1.0 - sorry for the delay, busy week.

@charlierudolph
Copy link
Author

No worries. Glad to see this merged. Thanks!

@kevinsawicki
Copy link

So it looks like this changed the following case:

require('cson-parser').stringify({a:{}}, null, 2)

Before

a: {}

After

a:
  {}

Was this intentional? It looks kind of weird to see the empty {} indented and the behavior seems to differ from JSON.stringify

@jkrems
Copy link
Contributor

jkrems commented Jun 15, 2015

@kevinsawicki Sorry for the regressions, fixed in v1.1.1 thanks to @charlierudolph.

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

Successfully merging this pull request may close these issues.

stringify defaulting to JSON
4 participants