filter a javascript iterator