You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using pluck() against an object whose properties contain "." characters (e.g. IP addresses) anywhere before the end of traversal, pluck() will return "undefined":
In the case where the object at the end of traversal has my example IP address key, it works:
> var o = { 'a': { 'b': { '1.2.3.4': true } } };
undefined
> jsprim.pluck(o, 'a.b.1.2.3.4');
true
This is fairly expected given the ambiguity around object traversal in this case, and I'm honestly not sure how to handle this particular case other than documentation. Perhaps pluck() could be expanded to take an Array of keys that it will work through? Something like:
jsprim.pluck(obj, [ '1.2.3.4', 'prop' ]);
For a real-world example of this, our ManateeClusterDetails class will populate pgs_peers with an object containing the cluster's peers indexed on the peer ID, which we currently set as the IP:PORT of postgres (see here). I was programatically using the ID as part of the key to pluck from this object, and it took me a little digging to figure out that pluck()substr's through the "." characters it finds to perform traversal, and that the keys I was putting together were problematic.
The text was updated successfully, but these errors were encountered:
When using
pluck()
against an object whose properties contain "." characters (e.g. IP addresses) anywhere before the end of traversal,pluck()
will return "undefined":In the case where the object at the end of traversal has my example IP address key, it works:
This is fairly expected given the ambiguity around object traversal in this case, and I'm honestly not sure how to handle this particular case other than documentation. Perhaps
pluck()
could be expanded to take an Array of keys that it will work through? Something like:For a real-world example of this, our ManateeClusterDetails class will populate pgs_peers with an object containing the cluster's peers indexed on the peer ID, which we currently set as the IP:PORT of postgres (see here). I was programatically using the ID as part of the key to pluck from this object, and it took me a little digging to figure out that
pluck()
substr
's through the "." characters it finds to perform traversal, and that the keys I was putting together were problematic.The text was updated successfully, but these errors were encountered: