evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a real-time product feed processor that displays products progressively as they arrive from a streaming JSON API, without waiting for the complete response.
Your implementation should:
The system should be efficient and responsive, showing products immediately as they stream in rather than blocking until all data has been received.
When streaming begins:
When streaming completes:
/**
* Processes a streaming JSON feed of products from the given URL.
* Calls onProduct for each product as it arrives in the stream.
* Calls onComplete when the entire feed has been processed.
*
* @param {string} url - The URL of the streaming JSON endpoint
* @param {Function} onProduct - Callback invoked for each product: (product) => void
* @param {Function} onComplete - Callback invoked when complete: (allProducts, count) => void
* @returns {Object} Stream controller with an abort() method
*/
function processProductFeed(url, onProduct, onComplete) {
// Implementation here
}
module.exports = { processProductFeed };{"products":[{"name":"Widget","price":10},{"name":"Gadget","price":20}]}, onProduct is called twice (once for each product) and onComplete is called with count 2 @test{"products":[]}, onComplete is called with count 0 and empty array @test{"products":[{"name":"Item A","price":5},{"name":"Item B","price":15},{"name":"Item C","price":25}]}, onProduct receives each product object progressively and onComplete receives all three products @testProvides streaming JSON parsing capabilities for progressive data processing.