Fair criticism of the above code, which I threw together to explain the problem. Unfortunately that doesn’t change the actual bug.
(if you use the above code referencing the peons variable correctly, you will hit the bug. If you reference the peon variable incorrectly, you actually just hit an error because peon is undefined)
Also, it shouldn’t actually matter, because if peon were any variable that correctly dereferenced ‘getNearest()’, then it should also return an item that can be found in the items array…
I’ve reproduced the bug. Tracking it over here. I think it is something to do with the API protection turning the object into not-quite-the-same object. Thanks for the bug report.