-
Notifications
You must be signed in to change notification settings - Fork 9
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
transform arguments are not passed correctly #137
Comments
Hi @xyse thanks for raising this, I will have a look into this next week. In the transform function are you looking to establish the length of the |
Well I want to map the null values so it would be best to just pass an array of them. When getting undefined I can assume every If there is no There could also be an option like |
As a temporary workaround, I think the following may do what you need for now? This caters for item.bar being null, being undefined, or not being set at all (which is not quite the same as being set to undefined, if that matters...)
|
It would be possible to do it like that, but for my use-case–I'm pulling the mappings from a database and automating the map('').to('') part by reading through each row of the db–it's not quite suited, there are also some other complications. I just forked it for now and changed the But there should be a cleaner solution I think. The workaround u posted of course is fine for certain use-cases. |
When I execute the following code:
I would expect to get
[true, null]
as a transform argument for the foo mapping and[null, null]
for the bar mapping. The problem is, I noticed when all the occurrences of an object's property in an array are null, we instead getundefined
. So in this case we get[true, null]
andundefined
.This way, using my custom transform I cannot transform the value of bar, as I cannot infer the length of the array from
undefined
. I think just passing the[null, null]
array would be a better solution, as it gives more possibilities to map the null value in the custom transform.The reason for this seems to be this part of the ./src/lib/object-mapper/get-key-value.js :
The text was updated successfully, but these errors were encountered: