-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Currently, the harFromMessages function in the chrome-har module does not support asynchronous iteration using for await...of. This limitation makes it difficult to process asynchronous streams of messages efficiently.
I would like to request adding support for for await...of to the harFromMessages function so that it can accept an AsyncIterator. This would allow users to process asynchronous streams of messages more efficiently.
As an alternative, users can manually collect all messages into an array before passing them to harFromMessages. However, this approach is not efficient for large streams of messages and can lead to high memory usage.
Here is an example of how the updated harFromMessages function could look with support for AsyncIterator:
async function harFromMessages(messages, options) {
options = Object.assign({}, defaultOptions, options);
const ignoredRequests = new Set(),
rootFrameMappings = new Map();
let pages = [],
entries = [],
entriesWithoutPage = [],
responsesWithoutPage = [],
paramsWithoutPage = [],
responseReceivedExtraInfos = [],
currentPageId;
for await (const message of messages) {
// Process each message
console.log(message);
}
// Rest of the function logic
}
module.exports = { harFromMessages };