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

.flatten doesn't preserve empty objects. #13

Closed
lxe opened this issue Jul 24, 2014 · 2 comments · Fixed by #14
Closed

.flatten doesn't preserve empty objects. #13

lxe opened this issue Jul 24, 2014 · 2 comments · Fixed by #14

Comments

@lxe
Copy link
Contributor

lxe commented Jul 24, 2014

console.log(flat.flatten({
  has: {
    value : 'someValue'
  },
  empty : {
    value : {
      nested: { }
    }
  }
}));

will return

{ 'has.value': 'someValue' }

instead the expected:

{ 'has.value': 'someValue', 'empty.value.nested': { } }

Edit:

To elaborate. It might seem as objects imply nesting, but if we don't account for empty objects, flatteining then deflattening an object will not preserve the original object structure.

In this example, doing flat.unflatten(flat.flatten(o)) will not retain the 'empty.value.nested' tree.

@timoxley
Copy link
Contributor

You should submit a PR, or at least a failing test and I'll look at it.

@timoxley
Copy link
Contributor

Oh you have.

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 a pull request may close this issue.

2 participants