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

If you leave mutate as false, arrays are converted to objects with index numbers as properties #18

Open
TreyOverton opened this issue May 4, 2023 · 1 comment

Comments

@TreyOverton
Copy link

Before:

const source = {
  id: '123',
  who: { name: 'morewow' },
  owner: { person: 'some guy' },
  empty: [],
  nothing: {},
  thisisnull: null,
  stuff: [ 'thing', 'dude' ],
  junk: undefined,
  nested: { useless: undefined }
}

After: rundef(source, true, 1);

{
  id: '123',
  who: { name: 'morewow' },
  owner: { person: 'some guy' },
  empty: [],
  nothing: {},
  thisisnull: null,
  stuff: [ 'thing', 'dude' ],
  nested: {}
}

After: const cleaned = rundef(source, false, 1);

{
  id: '123',
  who: { name: 'morewow' },
  owner: { person: 'some guy' },
  empty: {}, // array became object
  nothing: {},
  thisisnull: null,
  stuff: { '0': 'thing', '1': 'dude' }, // array became object
  nested: {}
}
@TreyOverton
Copy link
Author

Looks like line 10 of index.js checks for objects, which includes arrays, but doesn't treat arrays differently.

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

No branches or pull requests

1 participant