-
Notifications
You must be signed in to change notification settings - Fork 1
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
Handle the case where properties in new data can be multi-level path strings #3
Conversation
|
||
var augmentedNewData = {}; | ||
augmentedNewData[path] = newData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a wrapper obj, which has the passed-in path
as its only key, where the value is newData
. Then toss it into the helper function _convertObjToLevels
, which recursively makes levels for all keys (including nested ones) with path strings (i.e., strings with "/"
in them).
@daguej Ping on this. |
Do we ever see anything like:
|
@daguej Commit pushed - data conversion function should now handle all kinds of cases where the keys inside an object are "concatenated" together at any level with "/"s. Example input:
Corresponding output:
|
ccf083b
to
713cfae
Compare
return inputObj; | ||
} | ||
return inputObj; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray spaces
713cfae
to
97ab280
Compare
Fixed spaces. :) |
// If the current raw object is a scalar or just the empty object, navigate to | ||
// where this raw object should live by walking down the path in resultObj, and | ||
// put this raw object there. | ||
if ((typeof currentRawObj !== 'object') || (!Object.keys(currentRawObj).length)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential performance optimization: we'll end up enumerating all of the keys of the object twice -- here and at 492.
Since firebase doesn't support empty objects, can we avoid the Object.keys(currentRawObj).length
altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot that Firebase does not support empty objects, so there is no need for this check. Will push changes shortly.
97ab280
to
28b2045
Compare
Ping on this again. :) @daguej |
Released as v2.0.1 |
Should fix: https://github.com/casetext/cases-on-fire/issues/3465